Repository navigation
Let verify_turnstile_request hand a failed check to a handler - #56
Merged
Merged
Conversation
henrikbjorn
force-pushed
the
failure-handler
branch
from
November 12, 2026 12:17
2e5e9a3 to
0046c3d
Compare
A failed check answered a bare 400, so a person who failed it saw a blank page instead of the form, and a Cloudflare timeout surfaced as a 500. Tavle and Studio each carried the same patch to fix both. with: takes a method name or a lambda, defaulting to the 400 in the signature as rate_limit does, and a block can be passed instead. The handler is resolved as rate_limit resolves its with:. The verifier reports a Faraday error through Rails.error and answers false, so controllers never see Faraday. The gem used Faraday without requiring it, and only worked because the apps load it. Rails.error needs Rails 7.
henrikbjorn
force-pushed
the
failure-handler
branch
from
November 12, 2026 12:21
0046c3d to
13da1e8
Compare
Merged
henrikbjorn
added a commit
that referenced
this pull request
Nov 12, 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.
A failed check answered a bare
400, so someone who failed it got a blank page instead of the form. A Cloudflare timeout surfaced as a500. Tavle and Studio each carry the samelib/gem_ext/turnstiled/controller_methods.rbto fix both.The handler, modelled on Rails
with:takes a method name or a lambda. Its default, the400, sits in the signature, asrate_limitdoes it. A block can be passed instead, as withrescue_from.rate_limitruns itswith::with.is_a?(Symbol) ? send(with) : instance_exec(&with), registered as a lambdabefore_action.400.Network errors
Verifier#verifyrescuesFaraday::Error, reports it throughRails.erroras a handled warning, and answersfalse. Controllers never see Faraday.Also
require "faraday": the gem used Faraday without requiring it, so it only worked because the apps load Faraday themselves.Rails.errorneeds Rails 7.Checked
a challenge transport failure is handled like a refusalreplacesTurnstiled.verifywith a method that raises, which skips the verifier's rescue. Delete it when Tavle upgrades, since the gem's verifier test covers that case.🤖 Generated with Claude Code