Standardize POST /notify/:id response shape — always include stored field #13

Merged
matt merged 1 commit from mailship-nl0-post-notify-response-shape-ok-skipped-la-387 into main 2026-09-14 20:00:32 +00:00
Collaborator

mailship-nl0

Fix a mismatch between the documented POST /notify/:id response contract and the actual implementation: the endpoint now always includes a stored boolean, even when the event is not found at the relay.

Changes

  • src/server.ts — Changed the "event not found at relay" response from { ok: true, skipped: true } to { ok: true, stored: false }. This standardises the shape to { ok: true, stored: boolean } across both code paths (event found and event skipped), matching the README.md contract.

  • README.md — Added a paragraph documenting the skip case: when the relay does not have the requested event, the endpoint returns { ok: true, stored: false } rather than erroring.

  • test/notify-response-shape.test.ts — New vitest test that creates a confirmed subscription, starts the server, POSTs with a non-existent event ID (mocks @welshman/net's load to return empty), and asserts the response includes stored (not skipped) with value false.

How to test

Run pnpm test:unit — the new test notify_response_shape > returns stored=false instead of skipped=true when event not found will verify the fix. All existing tests continue to pass.

mailship-nl0 Fix a mismatch between the documented POST /notify/:id response contract and the actual implementation: the endpoint now always includes a `stored` boolean, even when the event is not found at the relay. **Changes** - **src/server.ts** — Changed the "event not found at relay" response from `{ ok: true, skipped: true }` to `{ ok: true, stored: false }`. This standardises the shape to `{ ok: true, stored: boolean }` across both code paths (event found and event skipped), matching the README.md contract. - **README.md** — Added a paragraph documenting the skip case: when the relay does not have the requested event, the endpoint returns `{ ok: true, stored: false }` rather than erroring. - **test/notify-response-shape.test.ts** — New vitest test that creates a confirmed subscription, starts the server, POSTs with a non-existent event ID (mocks `@welshman/net`'s `load` to return empty), and asserts the response includes `stored` (not `skipped`) with value `false`. **How to test** Run `pnpm test:unit` — the new test `notify_response_shape > returns stored=false instead of skipped=true when event not found` will verify the fix. All existing tests continue to pass.
hudson added 1 commit 2026-09-14 17:43:42 +00:00
Bug: when the event was not found at the relay, the handler returned
{ ok: true, skipped: true }, which did not match the documented contract
{ ok: true, stored: boolean } in README.md.

Fix: change the 'skipped' response to { ok: true, stored: false }, so the
response shape is consistent across all code paths.

- src/server.ts: changed line 287 from { ok: true, skipped: true } to
  { ok: true, stored: false }, with updated comment
- README.md: added a note documenting the skip case (stored: false)
- test/notify-response-shape.test.ts: new test that asserts stored=false
  and that skipped is never present
matt approved these changes 2026-09-14 20:00:29 +00:00
matt merged commit 2c257dedcd into main 2026-09-14 20:00:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: matt/mailship#13
No description provided.