Skip to content

fix(portal): every portal form refuses a patch that took its name - #485

Merged
allisonmahmood merged 3 commits into
mainfrom
t3code/implement-issue-371
Oct 2, 2026
Merged

allisonmahmood merged 3 commits into
mainfrom
t3code/implement-issue-371

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Closes #371.

#362 bound the Retire and Delete confirmations to the patch's ID. The other portal forms (Restore, Reassign, and the card's description, sharing and rollback forms) still looked their patch up by 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 acted on the replacement. An owner's stale sharing form could make a different patch public.

Every portal POST form now carries expectedPatchId. That includes the Restore button on an off patch's own address page, which posts into the same handler. The forms open through one actionForm helper that writes the ID, so a new form can't leave it out. The handler checks the ID once, before anything else:

  • If the ID is mismatched, it answers 409 on the card with "This name now belongs to a different patch. Nothing was done."
  • If the ID is missing (a tab opened before this change), it answers 409 with "This form is out of date. Nothing was done."
  • If it matches, only that ID reaches the Patches mutation. Every existing precondition still runs, and the mutation signatures are unchanged.

The ID check runs before the owner/admin check. Otherwise an owner's stale form at a name now held by someone else's patch would get "Only the owner or an admin can do that", which is misleading. A form whose ID matches still gets the same 403 as before.

Tests: #362's name-reuse test now covers all seven actions, using each page's real hidden fields. On the old code, description, sharing, restore and reassign returned 303 and changed the replacement patch, and rollback refused with the wrong notice. Now each gets 409 on the card, for both a mismatched and a missing ID, with both patches unchanged. A new test covers a different owner's patch taking the name. pnpm verify passes all 8 stages.

Made by Claude Opus 5.5 via Claude Code; reviewed by GPT 6.1 Sol via codex.

@github-actions github-actions Bot added area:server Touches the server area area:core Touches the core area area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines labels Oct 2, 2026
allisonmahmood and others added 3 commits October 2, 2026 22:00
Restore, Reassign and the card's description, sharing and rollback forms
looked their patch up by name on submit. After a rename, a form left open
acted on whichever patch claimed the old name; an owner's stale sharing
form could make a different patch public.

Every portal POST form, including the restore button on an off patch's
address, now carries expectedPatchId. The POST handler checks it once,
before dispatching on the action: a mismatch or a missing id answers 409 on
the card with nothing done. Retire and Delete's per-case checks fold into
the shared one.

Closes #371

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ener writes every form's id

Review follow-ups for #371. The patch-id check now runs before the
owner/admin check, so an owner's old form answers "This name now belongs to
a different patch" even when someone else's patch took the name, not 403.
Every portal form opens through actionForm, which writes expectedPatchId,
so a new form cannot forget it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ries the patch id

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the t3code/implement-issue-371 branch from e11240f to 3769b9c Compare October 2, 2026 20:00
@allisonmahmood
allisonmahmood merged commit ff3aa54 into main Oct 2, 2026
11 checks passed
@allisonmahmood
allisonmahmood deleted the t3code/implement-issue-371 branch October 2, 2026 20:11
allisonmahmood added a commit that referenced this pull request Oct 3, 2026
…wice (#496)

# What changed

The nested CSS watch test in `pageImports.test.ts` flaked on CI (`test
(22)` on #485). It read one watcher result per file write. A plain write
truncates and then writes, which can trigger two rebuilds, so a stale
duplicate refusal could stand in for the fixed build.

The test now saves by renaming a complete file into place, and its
`next()` skips a result identical to the one it last returned. These are
the mitigations the dev server's watch test already uses (`save` and
`inspectedChanges` in `devServerWatch.test.ts`). Assertions stay outside
the wait, so a new error or unexpected CSS still fails. No production
code changes; triage found no production defect.

Closes #487

## How it was verified

- [x] `pnpm test` passes locally
- [x] Added or updated tests covering this change

- Temporary checks (not shipped): pushing a duplicate refusal into the
queue before and after the fix write fails the old test, and the new
test reaches the blue build. The new test still fails on a differing
refusal after the fix, or on a fix that writes green instead of blue.
- `isDeepStrictEqual` treats two `LocalError` refusals with the same
code and message as equal, and different ones as unequal, on Node
22.22.0 and 24.20.0.
- Looped 50 times each on Node 22.22.0 and 24.20.0, run concurrently:
100/100 passed.
- `pnpm verify`: format, lint, typecheck, test (1625/1625),
postgres-concurrency, cli-smoke, tier2-smoke and browser pass.
- After rebasing onto `b320800` (#497), which adds an unrelated
`it.each` build test to the same file: looped 25 times each on Node
22.22.0 and 24.20.0, 50/50 passed; format, lint and test typecheck pass.

## Release impact

- [ ] **Breaking**
- [x] **Not breaking**: test only.

## Review

- GPT 6.1 Sol (codex): no findings.
- `/code-review` standards and spec passes: no hard findings. The file's
node-builtin waiver reason now covers the deep comparison.

Made by Claude Opus 5.5 via Claude Code; reviewed by GPT 6.1 Sol via
codex.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Touches the core area area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:m 100-500 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant