Repository navigation
Document the reorder-id check and pin its error's key order in the test - #683
Conversation
The helper had no doc comment saying what it returns. The test compared with toStrictEqual, which ignores key order, so a change that reordered the error's keys or its details lists would still have passed. It now also compares the JSON, which is what the API sends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Guz4o1w9DQYUMyTAsjLMcX
Tophat: passedb541936 changes only a doc comment in
Not UX: nothing a person sees or any API response changes. No screenshots: there's no screen to show. Session: https://claude.ai/code/session_01NvuNuwcHA6KexsEkHANMFD Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
Review: passed (round 1)
The PR adds a doc comment above everyIdOnceError and pins the error's key order in its test. Both "Done when" items from #682 are done. The comment matches what the function returns: serviceError('invalid_input', …) when there are missing, unknown or duplicate ids, and null otherwise. The test keeps toStrictEqual for a readable diff and adds a JSON.stringify comparison. Because the expected object includes all three details keys and every top-level key, a reorder at either level now fails the test, and the tophat confirmed that by swapping missing and unknown. The helper and its callers are unchanged, so "no behaviour change" holds.
Blocking (0): none.
Optional (0): none.
Earlier threads: none. Copilot couldn't review (quota used up).
Checks: CI is green on b541936 (lint-type-test, e2e, CodeQL). The tophat passed on this same SHA. Locally I read the diff, the helper and the issue's outline, and went through the repo checklist. No schema, policy, help, legal or CHANGELOG change is needed. Not UX, not high-risk, so it goes to merge.
https://claude.ai/code/session_01V899RJV71vaAwB2qidD6kT
Generated by Claude Code
Through the server, telemetry and screen branches. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UW9ZpEu4MWkeqTv2Qe14ks
Fixes #682.
The problem
everyIdOnceErrorinsrc/services/reorder-ids.tsis exported and called byreorderSlotsandreorderFields, but had no doc comment saying what it returns. Its test, "preserves the complete error and the order of each invalid ID list", compared withtoStrictEqual, which ignores key order. A change that reordered the error's keys or itsdetailslists would still have passed, even though the API sends them in that order.The fix
everyIdOnceError: theinvalid_inputerror for an id list that doesn't name every current id exactly once, ornullwhen it does.toStrictEqual(it gives the readable diff) and also comparesJSON.stringifyof the result withJSON.stringifyof the expected object. The expected object was already written in the orderserviceErrorbuilds, so it passes unchanged.The helper's behaviour and its callers are untouched. Nothing anyone sees changes, so there's no CHANGELOG entry.
Tests
To check that the new assertion catches a reorder, I swapped
missingandunknownin the helper'sdetails. Both cases (slot and field) failed on the JSON comparison, and passed again once I put the order back.pnpm lint && pnpm typecheck && pnpm knip && pnpm testpass locally (147 files, 1805 tests). No service logic changed, so I didn't runtest:db.Generated by Claude Code