Skip to content

fix(registration): say why a sign-up was refused, in the report form's words (#259) - #345

Merged
Ardnived merged 6 commits into
mainfrom
claude/fix-259-signup-refusals
Oct 31, 2026
Merged

Ardnived merged 6 commits into
mainfrom
claude/fix-259-signup-refusals

Conversation

@Ardnived

@Ardnived Ardnived commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The sign-up form used to explain only one refusal, the captcha one. Every other code SahajCloud's intake returns for a registration showed "Something went wrong" above the server's English sentence. This PR gives every code its own sentence, and a refusal the visitor can fix now lands on the field that caused it. This addresses one success line of #259: "When either form turns a visitor away, it tells them what to change, in the same words for both forms."

RegistrationErrorCode now covers every code the registration create path can return, read from SahajCloud main (d9698feb). The codes come from three places: the write guard, gateRegistration and prepareUserSubmission.

Code Registration form now shows Report form shows
invalid_email (field senderEmail) common.report_errors.email, on the Email field same key
disposable_email (field senderEmail) common.report_errors.disposable_email, on the Email field same key
urls_not_allowed (field name or a question key) common.report_errors.urls_not_allowed, on that field same key
captcha_failed registration.form.captcha_retry (unchanged) common.report_errors.captcha: the same sentence, with "send" where we say "register"
captcha_unavailable registration.form.captcha_retry common.report_errors.send_failed
content_unscannable (unreachable today) registration.form.captcha_retry common.report_errors.send_failed
event_not_found (404) common.errors.unavailable, then the event is refetched n/a
external_registration, event_ended, registration_closed, event_full unchanged; event refetched n/a
anything uncoded (offline, 5xx, unknown code) "Something went wrong" plus registration.form.captcha_retry; the thrown message is never shown send_failed
  • One table for the three input refusals. INPUT_REFUSAL_KEYS (organisms/ReportIssueForm/refusal-copy.ts) holds the copy, and both forms spread it into their own maps. So those sentences cannot drift apart between the forms. The report form owns the file, because the keys are its own common.report_errors.*.
  • Field refusals. These go through setError with shouldFocus. The visitor sees aria-invalid, the FormField role="alert" and aria-describedby, and focus moves to the field. The error clears when they edit the field. The form-level alert is suppressed for these, so the sentence is announced once.
  • asRefusal carries errors[].data.field through to RegistrationRefusedError. A malformed field costs only the field, never the code beside it. UserSubmissionError does not carry it — the report form has no field to put a sentence on.
  • Turnstile resets on every failure, matching the report form. Before, it reset only on coded refusals, but a 500 after the guard has also spent the token.
  • The event is refetched only after a refusal about the event: the four state codes and event_not_found. It used to be refetched after every refusal except the captcha one.
  • No host-visible change. No origin, attribute or CSP entry changes, so docs/embedding.md and CHANGELOG.md are untouched.

Part of #259. It does not close it, because that goal has other open lines.

Translation gap (needs SahajCloud copy)

The words are now the same in both forms, but two shared sentences were written for the report form, and they are not quite right on sign-up:

  • common.report_errors.disposable_email ends "…or leave it blank". The registration email is required, so that half is false here. It is also false on a report form whose operator made email required.
  • common.report_errors.urls_not_allowed says "in the message … send again". On sign-up it appears under the name or a question answer.
  • A related drift: the client-side check says "Enter a valid email" (registration.errors.email), and the server refusal says "Enter a valid email address." on the same field.

The honest fix is neutral wording in sy-atlas-translations, or a registration-specific key. Either one is a SahajCloud copy change, so this PR uses the existing keys. No SahajCloud schema change is needed.

Tests

  • New RegistrationForm.submit.test.tsx (jsdom, SDK-boundary mock) covers:
    • each address and link refusal lands on its field, with focus, and gives one alert;
    • the error clears on edit;
    • the six request-level codes each show their own sentence;
    • the uncoded fallback shows the retry sentence and resets the challenge;
    • which refusals refetch the event.
  • mutate.test.ts: field is carried for both refusal shapes, and a malformed field keeps the code.
  • ReportIssueForm.submit.test.tsx: the three shared codes render the same keys as the registration spec.
  • Each new assertion was watched failing first: 9 of 11 against the old form, the refetch spec against the old condition, and the field and malformed specs without their fixes.
  • Lean gate (check.sh) passes: lint, typecheck, and 156 files / 1849 tests.
  • Stories: two new Ladle sections, "Refused · on a field" and "Refused · the request". They are not checked in a browser, because the running Ladle server serves the main checkout.

Local review

An adversarial review read the diff and SahajCloud main. It found no missed codes, and the mechanics were sound.

Fixed in cc913c9e:

  • the malformed-field parse;
  • a story description that claimed editing clears the error, which it does not before a submit;
  • two inaccurate comments, one on the token reset and one on the "twin" claim;
  • the list of unreachable codes;
  • specs for the name mapping and for which refusals refetch the event.

Fixed in b4408d8, from the PR's own adversarial review:

  • UserSubmissionError.field is gone. Only RegistrationRefusedError had a reader.
  • the shared refusal table moved out of molecules/FormField/, which never imported it, to the report form that owns the copy. InputRefusalCode went with it — nothing read it.
  • the story-only refusal no longer holds state inside the form. The story builds the RegistrationRefusedError and passes it, so the live path keeps a mount effect and one ??.
  • the REFUSAL_MESSAGE_KEYS doc is eleven lines, down from twenty-one.

A branch-level /security-review ran, because the diff touches src/config/api/. It found nothing.

Left as-is:

  • The copy gap above. It needs SahajCloud.
  • Per-field refusals in the report form. Every field there carries announceError={false} and validates per keystroke (fix(ui): announce form errors, manage focus, respect reduced motion #102), so a setError sentence would never be announced, and the form-level alert is what speaks. Unifying the two forms means reopening that design.
  • Focus after a request-level refusal. Focus is lost because the submit button disables. This predates the PR, the alert still announces, and the report form behaves the same way.
  • The fallback after a 2xx with a drifted envelope says "register once more". That path is contract drift, and it is already its own parse failure.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mg9rjWpunuLNgiuyGeP9RL

Ardnived and others added 2 commits October 30, 2026 13:19
…s words (#259)

The sign-up form mapped one write-guard code, `captcha_failed`. Every other
refusal SahajCloud's intake raises for a registration reached the visitor as
"Something went wrong" over the server's English sentence: the address checks
on `senderEmail`, the link scan on free-text answers, `captcha_unavailable`,
and the gate's own `event_not_found`.

`RegistrationErrorCode` now covers every code the registration create path can
return, and the form maps each one:

- invalid_email, disposable_email, urls_not_allowed take the report form's own
  keys from one shared table (`INPUT_REFUSAL_KEYS`), which both forms spread,
  so neither can reword them alone. They land on the field SahajCloud names
  in `errors[].data.field` (now carried through `asRefusal`), with
  aria-invalid, aria-describedby and focus, and clear when edited.
- captcha_failed, captcha_unavailable, content_unscannable take the retry
  sentence, the registration twin of the report's captcha copy.
- event_not_found takes the panel's "can't be joined right now" and, like the
  state refusals, refetches the event.
- an uncoded failure keeps the generic title but adds the retry sentence, and
  never shows the thrown message. The challenge now resets on every failure,
  as the report form's does: a 500 after the guard ran has spent the token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From an adversarial review of the previous commit:

- `data.field` parses with `.catch(undefined)`, so a malformed field costs
  only the field and never drops the refusal code beside it.
- The token-reset comment said every failure spends the token; the address
  checks run before the captcha, so those cost only a fresh challenge.
- The copy-map comment called `captcha_retry` the report's twin for all three
  retry codes; it is that only for `captcha_failed`.
- The "Refused · on a field" story claimed editing clears the error. It does
  not there: nothing was submitted, so react-hook-form never re-validates.
- `mutate.ts` now lists every code the registration path cannot earn.

New specs pin the `name` field mapping, which refusals refetch the event
(the old `!== 'captcha_failed'` condition fails it), and the malformed-field
case (fails without the catch).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
sahajatlas-design b4408d8 Oct 31 2026, 12:35 AM

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 30, 2026
@sydevs-bot

sydevs-bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 00:21Z address-review · attempt 1 · session · done
  • 00:21Z address-review · attempt 1 · session
  • 00:13Z review-pr · attempt 2 · session · done
  • 00:13Z review-pr · attempt 2 · session
  • 20:31Z review-pr · attempt 1 · session · timed out

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Oct 30, 2026
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 31, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 31, 2026

@sydevs-bot sydevs-bot 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.

🧐 Adversarial review

The scope is right. #259's own build plan asked for exactly this — the refusal map widened past captcha_failed, reading errors[0].data.field — and the diff is that plus its tests. Nothing is smuggled in. I checked the code set against SahajCloud main and found no gap: urls_not_allowed can only name a submissionData key, so name and the question keys are the whole reachable set, and the four excluded codes are genuinely unreachable from this payload.

What the diff does not finish is the mechanism it starts. field is plumbed through asRefusal into both error classes, and only one form reads it.

Findings

  • should-fix — UserSubmissionError.field has no reader; the report form is left outside the mechanism this diff builds (mutate.ts:273).
  • consider — the story-only refusal costs three pieces of live machinery (RegistrationForm.tsx:260).
  • consider — refusal-copy.ts sits in a molecule folder that never uses it (refusal-copy.ts:14).
  • consider — the REFUSAL_MESSAGE_KEYS doc runs 24 lines, three of them about the other form (RegistrationForm.tsx:63).

What was checked

Read whole: RegistrationForm.tsx, mutate.ts, ReportIssueForm.tsx, refusal-copy.ts. Consumer side in SahajCloud main: antiSpamGuard.ts (checkNoUrls returns the scanned key as field), writeGuard/policies.ts (user-submissions.create lists no urlScanFields), submissionData.ts:221 (scans per key), prepareUserSubmission.ts:195 (refuse drops field for submission_data_invalid). Grepped src/ for every .field reader: lexical.ts and report-form.ts only. Reviewer profile read. The body carries no ## Preview link, and the sahajatlas-design deploy is the playground, so the two new stories were not opened.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/config/api/mutate.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 31, 2026
The diff added `field` to both refusal classes, and only
`RegistrationRefusedError` has a reader. The report form says a refusal
in one form-level alert: its fields are authored by the operator and
announce per keystroke (#102), so there is no field to carry a sentence.

Making that form read `field` means reopening #102's announcement
design, which this PR does not touch. So the member lives only where it
is read, and the asymmetry is stated on the class.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpunuLNgiuyGeP9RL
The story-only refusal held a `useState` inside the form so it could
construct a `RegistrationRefusedError` there. Taking the error itself as
the prop deletes that state: the story builds it, and the live path is
left with the mount effect and one `??`.

A Ladle story cannot reject the mutation the way the spec does. The
playground has no SDK boundary to mock, and the submit button is gated on
a solved Turnstile token it never gets, so the refusal has to arrive as a
prop.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpunuLNgiuyGeP9RL
The table sat in `molecules/FormField/`, which never imported it, and its
two consumers are both organisms. The keys are `common.report_errors.*`,
authored for the report form, so that form owns the file and the
registration form borrows it — the direction the copy already runs.

Also drops `InputRefusalCode`, which nothing read, and cuts the doc from
eleven lines to four.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpunuLNgiuyGeP9RL
Twenty-one lines for a six-entry table, three of them describing what the
report form's copy reads and why this form cannot borrow it. The
totality-split reason and the `event_not_found` choice are the parts a
reader cannot re-derive; the captcha paragraph restated the table under
it and the token reset the handler already explains.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpunuLNgiuyGeP9RL
@sydevs-bot

Copy link
Copy Markdown
Contributor

All four adversarial-review threads adopted, in b4408d8.

  • mutate.ts:273 — dropped field from UserSubmissionError. Only RegistrationRefusedError read it.
  • RegistrationForm.tsx:260 — the story builds the error now, so no story state sits in the form. The re-show after a success does not happen.
  • refusal-copy.ts:14 — moved to the report form, which owns the copy. InputRefusalCode dropped, unread.
  • RegistrationForm.tsx:63 — doc cut to eleven lines from twenty-one.

Not built: per-field refusals in the report form. Its fields announce per keystroke (#102), so a field sentence is never announced. That needs #102's design reopened.

Security review clean. Lean gate green at 156 files and 1849 tests. Docs checked, nothing stale.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 31, 2026
@sydevs-bot
sydevs-bot enabled auto-merge October 31, 2026 00:37
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Oct 31, 2026
@Ardnived
Ardnived merged commit 8d1c6ef into main Oct 31, 2026
60 of 65 checks passed
@Ardnived
Ardnived deleted the claude/fix-259-signup-refusals branch October 31, 2026 04:43
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants