Skip to content

portal: Restore, Reassign and inline card forms still resolve the patch by name #371

Closed

Description

@allisonmahmood

PR #362 (issue #339) bound the Retire and Delete confirmations to the patch's stable ID so a stale form cannot mutate a patch that later took the name. Restore, Reassign and the card's inline description, sharing and rollback forms still resolve the patch by its mutable name on POST. Reassign is the most exposed: both patches can share an owner, so an old Reassign confirmation left open across a rename and name reuse would hit the replacement.

Fix the same way as #362: carry expectedPatchId in each form, refuse on the card when the name no longer resolves to it, and pass only the validated ID to the mutation.

Found by grok build reviewing PR #362; filed by Claude Fable 5.1 via Claude Code.

Activity

  1. added
    bug
    area:server
    area:ui
    on Sep 23, 2026
  2. allisonmahmood commented on Oct 2, 2026

    @allisonmahmood
    OwnerAuthor

    This was generated by AI during triage.

    Agent Brief

    Category: bug
    Summary: Every portal POST form carries the ID of the patch it was rendered for, and the server refuses a form whose name now belongs to a different patch.

    Current behavior:
    #362 bound the Retire and Delete confirmations to the patch's stable ID. The other five portal forms (Restore, Reassign, and the card's inline description, sharing and rollback forms) still look the patch up by its name when submitted. A live patch's former name can be claimed by another patch, so a form left open across a rename and name reuse acts on the replacement.

    Reproduced during triage with a portal test. The test renders a form for patch A, renames A by publishing it under a new name, publishes B under A's old name, then posts the untouched form:

    Form Result on B Why the existing precondition passed
    Sharing made public, 303 expectedScope is company for both
    Reassign (admin) reassigned, 303 expectedOwnerUserId matches, since both patches share an owner
    Restore restored, 303 expectedState is retired for both
    Description overwritten, 303 expectedDescriptionUpdatedAt collides when neither patch has ever had a description (both null)
    Rollback refused, 409 expectedCurrentVersionId is unique, but the stale notice describes B's history as if it were A's

    Sharing is the worst case: an owner's stale form can make a different patch reachable by anyone on the internet.

    Desired behavior:
    Every POST form in the portal, covering card forms and confirmation pages for all seven actions (description, scope, rollback, retire, delete, restore, reassign), carries expectedPatchId. That includes the restore confirmation that an inline restore re-renders with 409 when it finds off sources. The POST handler checks the submitted ID against the patch the name resolves to once, before dispatching on the action, not per action as #362 does today:

    • The ID is mismatched: answer 409 on the card for the name's current patch with "This name now belongs to a different patch. Nothing was done." Do not re-render a form for the current holder.
    • The ID is missing (a tab opened before this change): answer 409 on the card with an out-of-date notice. The wording must fit inline card forms as well as confirmations, so it should no longer say "confirmation".
    • On a match, only the validated ID reaches the Patches mutation. Every existing precondition (owner/admin, state, scope, owner, version, description stamp, dependants, typed delete name) stays as it is and is still checked.

    Retire and Delete keep their current behavior, but their per-case checks fold into the shared one.

    Key interfaces:

    • The portal's POST handler for /patches/:name/<action>: one expectedPatchId check, ahead of the action switch, for all seven actions
    • The card's inline description, sharing and rollback forms, the restore control on off cards, and the Restore and Reassign confirmation forms each gain a hidden expectedPatchId
    • The Patches service mutation signatures do not change

    Acceptance criteria:

    • For each of the five newly covered actions, a portal test takes the rendered form's real hidden fields, renames the patch, publishes a new patch under the old name and posts the old form. It gets 409 on the card, with both patches unchanged, for both a mismatched and a missing expectedPatchId. Extend fix(portal): an old retire or delete form no longer hits a patch that took its name #362's existing "refuses an old … once its name belongs to another patch" test rather than writing a parallel one.
    • The current-form happy path for every action still succeeds (existing portal tests pass)
    • Retire and Delete still refuse a mismatched or missing ID with the same 409 behavior
    • docs/product.md's lifecycle section no longer says only Retire and Delete carry the patch's ID; it says every portal form does
    • pnpm verify passes

    Out of scope:

    • The CLI and lifecycle API, which resolve names at call time rather than from a stale form
    • The user deactivation and reactivation pick pages under /company/users/:id
    • Changing any action's own precondition or its notice wording, apart from the out-of-date notice above
    • Reserving former names or otherwise changing name reuse
  3. added
    ready-for-agent
    and removed
    area:server
    on Oct 2, 2026
  4. added 2 commits that reference this issue on Oct 2, 2026
    de93b1e
    3f85afe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:uibugready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions