Skip to content

Document the reorder-id check and pin its error's key order in the test - #683

Merged
richshaw merged 2 commits into
mainfrom
claude/issue-682-reorder-ids-doc
Oct 26, 2026
Merged

richshaw merged 2 commits into
mainfrom
claude/issue-682-reorder-ids-doc

Conversation

@richshaw

Copy link
Copy Markdown
Owner

Fixes #682.

The problem

everyIdOnceError in src/services/reorder-ids.ts is exported and called by reorderSlots and reorderFields, but had no doc comment saying what it returns. Its test, "preserves the complete error and the order of each invalid ID list", compared with toStrictEqual, which ignores key order. A change that reordered the error's keys or its details lists would still have passed, even though the API sends them in that order.

The fix

  • A doc comment above everyIdOnceError: the invalid_input error for an id list that doesn't name every current id exactly once, or null when it does.
  • The test keeps toStrictEqual (it gives the readable diff) and also compares JSON.stringify of the result with JSON.stringify of the expected object. The expected object was already written in the order serviceError builds, 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 missing and unknown in the helper's details. 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 test pass locally (147 files, 1805 tests). No service logic changed, so I didn't run test:db.


Generated by Claude Code

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
@richshaw richshaw added the pipeline:working A session is working on it right now label Oct 26, 2026 — with Claude
@richshaw
richshaw requested a balanced review from Copilot October 26, 2026 19:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@richshaw richshaw added pipeline:tophat pipeline:working A session is working on it right now and removed pipeline:working A session is working on it right now labels Oct 26, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Tophat: passed

b541936 changes only a doc comment in src/services/reorder-ids.ts and an assertion in its test, so there's nothing to click in the app and I didn't start it. I ran the affected tests instead.

Check Result What I saw
The test passes on the PR ✅ pnpm test src/services/reorder-ids.test.ts: 6 passed
The new assertion catches a key reorder ✅ With missing and unknown swapped in the helper's details, both "preserves the complete error and the order of each invalid ID list" cases (slot and field) failed. Restored, they pass again, and the working tree is clean
Helper behaviour unchanged ✅ The only change to reorder-ids.ts is the comment; the comment matches what the function returns (invalid_input or null)
Neighbours ✅ reorder-ids.test.ts plus slots.test.ts: 15 passed. pnpm lint and pnpm typecheck clean

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 richshaw added pipeline:review pipeline:working A session is working on it right now and removed pipeline:tophat pipeline:working A session is working on it right now labels Oct 26, 2026 — with Claude

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@richshaw richshaw added pipeline:merge and removed pipeline:review pipeline:working A session is working on it right now labels Oct 26, 2026 — with Claude
@richshaw richshaw added the pipeline:working A session is working on it right now label Oct 26, 2026 — with Claude
@richshaw
richshaw merged commit 4816dc4 into main Oct 26, 2026
5 checks passed
@richshaw
richshaw deleted the claude/issue-682-reorder-ids-doc branch October 26, 2026 21:26
@richshaw richshaw removed pipeline:merge pipeline:working A session is working on it right now labels Oct 26, 2026 — with Claude
richshaw pushed a commit that referenced this pull request Oct 27, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The shared reorder-id check has no doc comment, and its test doesn't pin the error's key order

3 participants