Skip to content

manual verification: fix csrf failure on the scan button - #337

Merged
leowilkin merged 1 commit into
mainfrom
fix/manual-verification-review-followups
Oct 6, 2026
Merged

leowilkin merged 1 commit into
mainfrom
fix/manual-verification-review-followups

Conversation

@leowilkin

Copy link
Copy Markdown
Member

production hotfix: clicking "scan with your camera" showed the generic "something went wrong" banner with nothing in sentry and no inquiry in persona.

cause

rails per-form csrf tokens are on under load_defaults 8.0. a per-form token is bound to the form's own action url. the scan button used formaction to post the shared upload form to the prepare-capture route, so the token never validated and every click raised InvalidAuthenticityToken. that exception is on sentry's default ignore list (hence no event), and the test env disables forgery protection (hence green specs).

fix

  • the scan button submits to the same url as the form with name="intent" value="scan", and submit_documents dispatches to prepare_capture on that intent.
  • new request spec turns forgery protection on, pulls the real token out of the rendered form and submits it, so this class of bug fails in ci from now on.

testing

manual verifications request spec: 28 examples, 0 failures. rubocop clean, erb lint unchanged (pre-existing autocomplete warnings only).

rails per-form csrf tokens (on under load_defaults 8.0) are bound to
the form's action url. the scan button submitted via formaction to the
prepare_capture route with the upload form's token, so every click
raised InvalidAuthenticityToken in production. that exception is on
sentry's default ignore list, which is why nothing showed up there, and
forgery protection is off in the test env, which is how it shipped.

the button now submits to the same url with intent=scan and
submit_documents dispatches to prepare_capture. added a request spec
that turns forgery protection on and submits the real form token.
@leowilkin
leowilkin force-pushed the fix/manual-verification-review-followups branch from ca5e3fb to 24d95a3 Compare October 6, 2026 22:01
@leowilkin
leowilkin merged commit a8fbedd into main Oct 6, 2026
7 of 8 checks passed
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.

1 participant