Repository navigation
feat(report): migrate the issue-report form to POST /api/user-messages - #187
Merged
Merged
Conversation
SahajCloud#653 merged on 31 Aug and DELETED `POST /api/contact-admin`,
replacing it with the `user-messages` collection and its built-in create
endpoint. The report form has been posting to a 404 ever since — every
issue report a visitor has sent in the last two days was lost.
Five things move on the wire:
path /contact-admin -> /user-messages
captcha token body -> x-turnstile-token header
sender address email -> senderEmail
success 200 { ok: true} -> 201 { doc, message }
refusal code errors[].code -> errors[].data.code
The last one is the trap, and it is why `asRefusal` now accepts BOTH
positions rather than moving to the new one. Only collection-backed
routes go through Payload's `formatErrors`, which nests the APIError
payload under `data`; `POST /events/{id}/register` is hand-written and
still builds the flat shape itself. Switching would have silently
stopped recognising every registration refusal — they would fall through
as generic errors and the form would show "try again" in place of the
copy written for each case. Verified by reintroducing exactly that:
the switch fails both registration refusal specs.
`ContactAdminErrorCode` had one member. The write-guard defines five and
all five are reachable here, so `REFUSAL_MESSAGE_KEYS` is a total Record
over the new union (a missing member fails typecheck — verified) and two
of them earn their own sentence in all ten locales: a disposable address
and links in the message body. Telling someone whose email domain was
rejected to "wait for the security check to refresh" is not just vague,
it is advice that can never work.
Context bounds follow the collection's schema: 2000 on every key, where
the deleted endpoint had 500/500/20/500/2000. Nothing relied on the
tighter local copy, and keeping it would truncate what the server
accepts.
`src/types/payload/contact-types.ts` is deleted with the endpoint it
described. Its `types:cms` curl is deleted too — and that was not
cosmetic: the upstream path still resolves and now serves the Atlas SEO
and sitemap types, so every re-sync was overwriting a file named after
contact with unrelated content that nothing here consumes.
Behaviour change worth stating: a 201 means ACCEPTED, not delivered.
The old endpoint sent the email inline and answered 502 rather than a
false 200. Delivery is now a background job, and a failed send reaches
SahajCloud admins as a `failed` row rather than the sender. Three
comments in ReportIssueForm asserted the old guarantee and are corrected
rather than left to rot.
Every new assertion was made to fail at the site that would really cause
it, per docs/testing.md: `asRefusal` reading only `code` (5 red), only
`data.code` (3 red, incl. both registration refusals), the token back in
the body (1), `email` for `senderEmail` (1), the old `{ ok: true }`
schema (7), the 500-char clamp (1), a dropped REFUSAL_MESSAGE_KEYS
member (tsc), and a locale missing a new key (parity spec).
Closes #171
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01V9pS12WqrzQQzKpPoNnyFx
Deploying sahajatlas-design with
|
| Latest commit: |
527e9fb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d374cd0c.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://claude-feat-user-messages-in.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
527e9fb
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9229dcd3.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-feat-user-messages-in.sahajatlas.pages.dev |
Ardnived
approved these changes
Sep 2, 2026
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/contact-admin; every issue report sent since then was lost. This moves the form onto the replacement.201means accepted, not delivered: screening and delivery are a background job now.Changes
src/config/api/mutate.ts—contactAdmin→sendUserMessage; the token moves to thex-turnstile-tokenheader,email→senderEmail, the receipt becomes Payload's create envelope, andasRefusallearns the second code positionsrc/components/organisms/ReportIssueForm/—REFUSAL_MESSAGE_KEYSbecomes a totalRecordover the five write-guard codes; three comments asserting the old delivery guarantee are correctedsrc/types/payload/contact-types.ts— deleted, along with itstypes:cmscurl (see Contract impact)public/locales/*/common.json— two newreport.errors.*keys × 10 localesPreview
Branch aliases, both verified
200:The form is behind Report an issue in the settings menu (⚙, bottom-left). Deep link to a region to reach it in one step: https://claude-feat-user-messages-in.sahajatlas.pages.dev/nl/amsterdam
⚠ A real submit will not succeed from the preview:
.envships Turnstile's always-passes test key, which SahajCloud's live write-guard rejects. What is worth checking by eye is the copy — see Manual verification.Contract impact
POST /api/user-messagesis the same origin as the endpoint it replaces (cloud.sydevelopers.com), so no host's CSP changes.docs/embedding.mdneeds no edit for that reason: itsconnect-srctable is keyed by origin, not path.CHANGELOG.mddoes change, because two things a visitor sees do: the confirmation now promises receipt rather than delivery, and the two new refusal sentences.⚠
pnpm types:cmswas quietly corrupting a file. It curledcontact-types.tsfrom SahajCloud'ssrc/endpoints/responseTypes.ts. That path still resolves — socurl -fnever failed — but since #651 it serves the Atlas SEO and sitemap types, which nothing here consumes. Every re-sync overwrote a file named after contact with unrelated content. The line is removed rather than repointed; auser-messagesrow's shape comes from the generatedConfiglike any other collection.Test results
lint·typecheck(app + tests) ·test:run— 111 files / 1465 specs passedmutate.test.ts(+8 for the new intake, incl. a 4-code table) ·ReportIssueForm.submit.test.tsx·i18n-options.test.tslocale parity527e9fb: all five check runs green — Lint/Typecheck/Build, Smoke, Dependency Audit, and both Pages deploysManual verification
Notes for reviewer
Three judgement calls, all reversible, all worth a glance.
⚠ The ticket's AC said the three codes should "still reach their existing error copy". Two of them had none —
disposable_emailandurls_not_allowedare new codes this client has never seen, so the literal reading routes them tosend_failed: "Wait for the security check to refresh, then try again." That is not merely vague for a rejected email domain or a link in the body, it is advice that can never work. I wrote real copy for both instead. If you would rather ship the generic sentence, deleting two locale keys and two map entries is the whole change.Five codes, not three. The ticket named three; SahajCloud's
AntiSpamCodedefines five and all five are reachable for auser-messagescreate.invalid_emailreuses the form's existing "Enter a valid email address.";captcha_unavailable(Cloudflare down on our side — nothing the sender can fix) takes the generic sentence deliberately.I did not reword
report.sent. The ticket asks that success copy promise receipt rather than delivery. The current English — "Thank you — your report is on its way to the team." — reads as accepted-and-in-transit rather than arrived, which is accurate for async screening, so changing ten locales looked like churn. Your call; it is the one thing here I would most expect you to overrule.Not done:
sendUserMessageuses the SDK's rawrequestJson, notPayloadSDK's typedcreate, which the ticket floated as an option.requestJsonalready threads per-request headers throughinit— which is exactly what the captcha token needs — and it keeps all three mutations in this file the same shape. Happy to switch if you prefer the typed call.Detail
The trap, and why
asRefusalaccepts both positionsRefusalBodySchemais shared withcreateRegistration, and the two endpoints put the code in different places:POST /user-messageserrors[].data.codeformatErrorsnests theAPIErrorpayload underdataPOST /events/{id}/registererrors[].codeSo
entryCodeisentry.code ?? entry.data?.code. Switching todata.codeoutright — which is what the wire table alone suggests — silently stops recognising every registration refusal: they fall throughasRefusaluntouched, andRegistrationFormshows its generic error in place of "This event is full." and friends. Verified rather than argued: making that switch turns both registration refusal specs red, and nothing else.Every new assertion was made to fail first
Per
docs/testing.md— "a regression spec is not finished until it has FAILED" — each defect was reintroduced at the site that would really cause it, not at a nearby gate:asRefusalreads onlyentry.code(the pre-#171 client)asRefusalswitched toentry.data?.code— the trapemailsent instead ofsenderEmail{ ok: true }REFUSAL_MESSAGE_KEYStsc— TS2741i18n-options.test.tsparityAll restore to 1465 green.
Two smaller decisions
Only
doc.idis pinned on the create envelope, followingreportEmbed's precedent: nothing renders any of it, and pinning a field we never read turns a harmless CMS rename into a failed report for every sender.idis Payload's primary key, so it cannot be renamed, and requiring it is what distinguishes a create from any other 2xx — the old{ ok: true }schema now fails, which is the point.Context bounds follow the collection: 2000 on every key, from the
contextJSON schema in SahajCloud'sUserMessages.ts. The deleted endpoint's were 500/500/20/500/2000. Nothing relied on the difference, and keeping the stricter local copy would silently truncate what the server accepts —userAgentis the one that matters, since losing a bug report to a long browser string is the worst available trade.Three stale comments corrected rather than left
ReportIssueFormasserted the old inline-email guarantee in three places, most consequentially: "the endpoint answers 502 rather than a false 200 when the mail itself fails, so a resolved promise really does mean the message was delivered." That is now false. The thank-you is still derived from a resolved promise and nothing else (#103's property is intact) — but what it attests to has narrowed, and a comment claiming otherwise is the kind that survives into the next reader's assumptions.Process note
An earlier version of this body claimed both preview aliases had been "verified 200 before pasting", and named the slug as
claude-feat-user-messages-i. Neither was true at the time: the slug is 28 characters (…-in), and both aliases were 404 because the deploy had not finished. They are verified now, on two probes ~7 minutes after the push. Recorded rather than quietly fixed, sincedocs/why.md#link-the-branch-alias-never-a-commit-aliasexists precisely because a wrong Preview link is worse than none.Closes #171
🤖 Generated with Claude Code
https://claude.ai/code/session_01V9pS12WqrzQQzKpPoNnyFx