Repository navigation
fix(components): a required checkbox or select stops an untouched submit, and the submission proxy guards its input - #301
Merged
Conversation
An authored form's required checkbox was registered with no rule, so an unticked one posted `false` and the author's "required" did nothing. It now takes the same `required` rule as every other field, and its error message is named by the control's `aria-describedby`, as FormField does for the wrapped fields. A select with no authored default left `defaultValue` unset. The browser then selects the first enabled option (the placeholder is disabled), and react-hook-form reads that value on registration, so `required` could never fail and an untouched select posted its first option. Confirmed in Chromium before and after. It now starts on the placeholder's empty value, server render included; an authored default still wins. The new jsdom file covers what a submit does end to end: a success, a refusal that re-challenges instead of resending a spent token, the redirect and its scheme gate, and both required fields. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
…es any body `POST /api/submissions` forwarded a submission to SahajCloud with no `x-turnstile-token` header at all, spending an authenticated round trip on a write SahajCloud refuses every time. The proxy now gives that answer itself, the 403 `captcha_failed` envelope SahajCloud sends and the proxy already passes through, so the form renders exactly what it rendered. It also read the whole request body before validating it, whatever its size or type. A body is now refused unread past SUBMISSION_BODY_LIMIT (413) and unparsed unless declared JSON (415), both in the existing `invalid_request` envelope. The limit is derived from submissionSchema's own bounds at JSON.stringify's six-bytes-a-character worst case, so no body the schema accepts is ever refused for its size; a test pins that with every bound at its maximum. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Both same-origin proxies swallowed every SahajCloud failure into a 502 or a refusal, and api-routes.ts imported no Sentry at all, so a form that stopped landing — an outage, a rotated key, a key the intake started refusing — was visible only to the visitor who lost their message. A failure that is not the caller's (5xx, transport, timeout, a key SahajCloud refuses) now reports every time. Of the caller's, a 403 or 429 is the captcha or the rate limit working and stays unreported, and a 400 reports once per distinct code per isolate, the bound `reportedConfigGaps` set: it is how a contract drift shows, but also what a visitor with a disposable address earns. The event carries the status, the intake's code and the error's name, never SahajCloud's message, which may quote the body, the token or the visitor's address. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The Sentry cases sat at the end of api-routes.test.ts and set up their mock in the file-wide beforeEach. The related-route specs a sibling fix adds land at that same end, so both branches would edit one hunk. The cases now sit in one describe ahead of the refusal block, with their own setup, and the populate case joins them, so the file's tail and shared setup read as they do on main. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
reportProxyFailure dropped every upstream 403 as the caller's. But
SahajCloud answers a key it does not accept (stale, rotated, or missing
its role) with Payload's own Forbidden: a 403 whose envelope carries no
data.code. Checked against production with a GET and a bogus key:
403 {"errors":[{"message":"You are not allowed to perform this action."}]}.
So the outage the reporting exists for still reached Sentry with
nothing, on both proxies.
A 403 is now the caller's only on the submissions proxy, and only when
it carries the intake's code (captcha_failed and its siblings). An
uncoded 403 reports every time at level error. The populate proxy has
verified its caller's token before it calls, so every 403 there is ours
and reports. A 429 stays unreported.
Also says where SUBMISSION_BOUNDS.email comes from (RFC 5321), since the
comment above it attributes the other bounds to SahajCloud.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The refusal case failed every time in isolation and about one full run
in five. The mocked widget solved itself from a mount effect. After a
refusal, the remounted widget's effect called onSuccess('token-2')
outside act, and the second submit fired before React committed it,
so react-hook-form ran the previous render's onSubmit with token null.
The mock now hands the test a solve() that delivers the current
mount's token inside act, so the token is committed before the next
submit. The refusal case waits for the remount and then solves the fresh
challenge. It passed 6 of 6 runs in isolation and 5 of 5 full suite
runs. It still fails when the widget is not remounted on a refusal.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
The README said native HTML5 `required` validates on the client and
that the API returns field-level errors. The form is noValidate,
react-hook-form checks the authored `required` rules (now on a checkbox
and a select too), and /api/submissions answers { ok, code }. The form
renders every refusal as forms.general.submit_error and re-challenges.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | f8761f0 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 09:16 PM |
This was referenced Nov 19, 2026
Ardnived
approved these changes
Nov 19, 2026
Contributor
Author
|
🤖 no session running Written by the sydevs dispatcher. Sessions never edit this comment. |
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
consent: false, and an untouched select posted its first option. Both now stop at the field with the usual "field required" message. Screen readers get the error througharia-describedby, the same way the other fields do. A select with no authored default now starts on its placeholder. An authored default is still kept.POST /api/submissionsnow answers three refusals itself and never calls SahajCloud for them:x-turnstile-tokengets 403captcha_failed;invalid_request, without being read;invalid_request.api-routes.tsimported no Sentry at all, so a form that stopped working was visible only to the visitor who lost their message. The event carries only the status, the refusal code and the error's name. It never carries the body, the token, the visitor's address or SahajCloud's message.Nothing the visitor sees changes on a refusal. FormBuilder shows every non-ok answer as
forms.general.submit_errorand re-challenges the captcha.Findings addressed
F2a — a required checkbox was never checked.
components/organisms/FormBuilder/FormBuilder.tsx:118gives the checkbox the samerequiredrule as every other field. In the checkbox and minimal branch, the error<p>getsid=<name>-error, and the control names it througharia-describedby(FormBuilder.tsx:125). Checked on main in Chromium (HeadlessChrome 153): an unticked required checkbox postedconsent=false. Pinned byFormBuilder.interaction.test.tsx› "stops an unticked one, and names the error on the control", which fails against main'sFormBuilder.tsx, and by "posts a ticked one".F2b — a select started on its first real option. Without an authored default, a select now defaults to the placeholder's
''(FormBuilder.tsx:161), sorequiredcan fail. Measured in Chromium. On main, an untouched required select readclassesand the form posted it. With the fix, the value is'', the error shows and nothing is posted. An authored default (other) is kept. The server HTML marks the placeholderselected. Pinned by "starts a required one on its placeholder, so an untouched one is stopped" and byFormBuilder.test.tsx› "server-renders a select with no authored default on its placeholder". Both fail against main. "keeps an authored default" pins the authored case.F2c — a tokenless submission was forwarded upstream.
server/api-routes.ts:345now answers a missing or empty token with 403{ ok: false, code: 'captcha_failed' }, the status the proxy already passescaptcha_failedthrough with. The check runs after body validation, so a malformed body still getsinvalid_request. Pinned byserver/api-routes.test.ts› "the captcha token": "answers a tokenless submission as SahajCloud would, without calling it" and "reads an empty token as none". Both fail on main.F2d — no proxy failure reached Sentry. Both proxies call
reportProxyFailure(server/api-routes.ts:224):error.<proxy>:<code>per isolate, at levelwarning. This uses the capped-Set idea fromreportedConfigGaps.api-routes.ts:229). A refused API key gets an uncoded 403, not a 401. Checked against production with a GET:Pinned by "Both proxies — what reaches Sentry":
The positive cases fail against main, and the two bold ones fail against the branch's earlier
reportProxyFailure.F2e — an unbounded body of any type was parsed. Hono's
bodyLimitis registered ahead of the handler (api-routes.ts:322) and refuses with 413 pastSUBMISSION_BODY_LIMIT(server/validation.ts:96). The limit is 6 bytes per character, which isJSON.stringify's worst-case escape, taken oversubmissionSchema's own bounds, plus 4 KiB: 6 × (40 × (100 + 5000) + 254) + 4096 = 1,229,620 bytes. Before, there was no bound at all. AContent-Typeother thanapplication/jsongets 415 (api-routes.ts:333). The check is case-insensitive and allows parameters. Pinned by "the body gate":F12a (FormBuilder) — no interaction coverage. New jsdom file
components/organisms/FormBuilder/FormBuilder.interaction.test.tsx(9 cases). It covers:submit_error, the widget remounted, and the second submit sending the fresh token);javascript:redirect refused, with the confirmation shown instead.The Turnstile mock is solved inside
act. With the earlier solve-on-mount mock, the refusal case failed 5 of 5 times in isolation and about 1 run in 5 of the full suite. It now passes 6 of 6 in isolation and 5 of 5 full runs, and it still fails when the widget is not remounted after a refusal.Review follow-ups also in this PR:
SUBMISSION_BOUNDS.emailcomment now says that bound is RFC 5321's, not SahajCloud's;noValidateform and the{ ok, code }answer.Not in this PR
.env.productionand the Turnstile site key) belongs to feat(server): switch wemeditate.com over to the new site #288.captcha_failed. Nothing was POSTed to SahajCloud.reportedRefusalsshould becomecreateWarnOnce(server/warn-once.ts) once feat(components): a MeditationLibrary for the meditations index block #293 merges. That PR adds the shared "once per signature per isolate" helper. The level-errorpath stays separate.server/AGENTS.mdnotes that SahajCloud's edge rate-limit bucket keys on our egress address. If that is true, a 429 could mean every proxied submission is being limited, not one visitor. It deserves its own look once the bucket's key is confirmed upstream.*. Adding one needs a design decision, not a string, so no translation key is needed.siteKeyJSDoc,types/vike.d.tsand.env.examplestill say SahajCloud refuses a tokenless submission. The proxy now gives that samecaptcha_failedanswer on its behalf, so the outcome they describe is unchanged.Reconciled with open PRs
.env.production. Neither is touched here.lib/translations.en.jsonandserver/payload-types.ts. Both are untouched here, and no translation key is added.AGENTS.md. This PR adds one sentence toserver/AGENTS.mdonly.lib/submissions.ts,server/validation.tsorserver/api-routes.ts.server/api-routes.ts, the edits stay in the import block, the populatecatch, the helpers betweenregisterLivePreviewPopulateandregisterSubmissions, andregisterSubmissions. The related-content GET routes, which a sibling fix edits, are byte-identical to main.server/api-routes.test.ts, the new cases sit mid-file and the file's tail matches main.git merge-treeagainst every open PR branch, and every result was clean.Test results
.claude/skills/pr-prep/check.shon the pushed head (f8761f0, based on currentmain5ee6ded):mainbaseline of 1084. The changed files lint clean.tsc --noEmit: clean.vitest run: 130 files, 1243 / 1243 tests passed. Four more full runs also passed 1243 / 1243.pnpm build: not run (this bundle is not marked BUILD).🤖 Generated with Claude Code
https://claude.ai/code/session_01Mg9rjZcE8bs5uRJ6dsg6kw