Repository navigation
fix(commitments): stop returning editTokenHash from participant endpoints - #395
Conversation
|
Hi @jay23606, thanks for picking this up! Keeping the edit-token hash out of participant responses is a good fix. At your commit it does what it says: all four responses drop The catch is that Needs fixing before merge1. Saving an edit sends the hash again after the rebase. Your change wraps const { moved, editTokenHash: _h, ...commitment } = result.value;2. Moving to another slot sends the hash too. Main's move branch returns 3. Nothing tests the actual responses. Issue #394 asked for a test that no response includes expect(payload.data).not.toHaveProperty('editTokenHash');to the GET, PATCH and move tests in Worth considering4. Remove the hash in the service, not in each route. Only 5. An allow-list might be safer than removing one key. 6. The POST response depends on key order. It spreads Small things7. The unit tests can't tell "removed" from "set to undefined". 8. 9. Database tests. CLAUDE.md asks for Thanks again, this is a really useful fix. With the rebase and a few response tests it should be good to go. Generated by Claude Code |
a0774f1 to
0c38c77
Compare
richshaw
left a comment
There was a problem hiding this comment.
Hi @jay23606, thanks for the quick turnaround on the last round! Moving the clean-up into the service is a real improvement. The routes can't forget it any more, and the response checks on GET, PATCH and move, plus the toStrictEqual unit test, are just what we wanted.
One thing is left before this can merge, plus a few small ones. Details are in the inline comments.
Needs fixing before merge
1. There's now a second hash on the same rows. #396 landed while this PR was open and added idempotencyKeyHash. It's the same kind of server-only value as editTokenHash, and it still goes out on sign-up, view and edit. Dropping it alongside editTokenHash fixes it.
2. A retried sign-up's response isn't checked. The repeat path (same idempotency key) uses the helper too, but no test looks at its response. It's also the best place to check idempotencyKeyHash, since that's the one response where it's always set.
Worth considering
3. An allow-list would have caught this for free. Last time I said a list of allowed fields could wait for a follow-up. A second hash showing up within a day is a good example of why it's worth doing: building the public shape from the fields we want to send means new columns stay private by default. It would also let the queries skip fetching the hashes at all (.returning({...}) / .select({...})). Still fine as a follow-up if you'd rather keep this PR small. In that case, removing both hashes is enough for now.
Small things
- The
CHANGELOG.mdentry needs a wording tweak (suggestion inline). - The new POST check sits inside an unrelated cookie test, so a failure there would be hard to spot.
CI hasn't run on this PR yet because it comes from a fork. A maintainer needs to approve the run, and the database tests will run then.
Thanks again, this is really close!
Generated by Claude Code
added a new commit |
|
Thank you, running CI now |
|
This one just needs to conflicts resolved and then I can approve merge |
3f5718d to
81dab76
Compare
Summary
Participant create, read, edit, move, and retry service results remove both
editTokenHashandidempotencyKeyHashbefore routes receive them. The public row type derives from the removal helper's return type so the list of hidden fields is maintained in one place.Response assertions cover GET, both PATCH paths, and initial/retried POST responses. The changelog describes all participant paths and both hidden check values. Updated against main. Resolves #394.
Validation
pnpm typecheck,pnpm lint,pnpm knip, and Prettier on the changed files: passed.pnpm test src/lib/public-commitment.test.ts: 2 passed; verifies both properties are absent and the original row is unchanged.pnpm test: 1,142 passed, 4 failed. Three failures (missing values in.env.example, Windowsspawn pnpm ENOENT, and a CRLF-sensitive golden prompt) reproduce on the unchanged pre-follow-up branch. The fourth, a bearer-verifier timeout, passed when rechecked; the current and unchanged branches both have 97 passed / 3 failed in the focused failure recheck.Local dependency installation used pnpm's hoisted layout to avoid a Windows package-resolution failure; package manifests and the lockfile are unchanged.