Conversation
Contributor
|
Build failure @ygd58 if you don't mind taking one more pass 🙏 |
…d of raising verify_or_challenge caught exceptions from method verification only to emit payment_failed and then Kernel.raise -- the only failure path in this function that re-raises instead of returning a fresh challenge via new_challenge.call. Every other failure case (challenge id mismatch, binding mismatch, expired challenge, request mismatch, etc.) already returns new_challenge.call(credential, error, echo), producing a retryable 402. A method verification failure -- a typed PaymentError (declined, insufficient funds) or an unexpected error -- escaped instead. Rebased onto main's validate/broadcast intent lifecycle (stripe#73, stripe#74): the call site is now IntentLifecycle.call(intent, credential, request) rather than intent.verify(credential, request) directly, but the underlying bug -- and this fix -- is unchanged. IntentLifecycle falls back to the legacy #verify path for intents that don't implement #validate/#broadcast (see lib/mpp/server/intent_lifecycle.rb), which is the path this fix's regression tests exercise via ThrowingIntent. Flagged by the cross-SDK audit as AGR-2026-089. Canonical mppx's createMethodFn wraps method verification the same way every other failure path here already does. This is the same gap I already fixed in stripe/mpp-java's Verify.java (stripe#26). Fix Replace the rescue block's manual emit_payment_failed + Kernel.raise with return new_challenge.call(credential, e, echo). new_challenge.call already emits payment_failed internally when passed a non-nil error, so the manual emit_payment_failed call is redundant -- removed rather than left as a duplicate emission. Testing Three regression tests in test/mpp/test_server.rb, using a ThrowingIntent test double (mirrors the existing MockIntent, and correctly routes through IntentLifecycle's legacy-verify fallback since it implements neither #validate nor #broadcast): - a typed VerificationFailedError from intent.verify returns a fresh Mpp::Challenge instead of raising - a plain RuntimeError (not a typed PaymentError) also returns a fresh challenge rather than escaping uncaught - payment_failed fires exactly once (not twice), confirming the old manual emit call was removed rather than duplicated alongside new_challenge.call's own emission Still no rubygems.org access in my sandbox to run bundle exec rake test, but ruby -c confirms both files parse cleanly, and I traced the IntentLifecycle dispatch path by hand against its current implementation to confirm ThrowingIntent still exercises the intended code path after the rebase. Fixes tempoxyz/mpp-tools#211
ygd58
force-pushed
the
fix/verify-catches-intent-verify-exceptions
branch
from
September 18, 2026 21:10
587afc8 to
80c83e2
Compare
Contributor
Author
|
Thanks for the ping — the branch was rebased onto an older |
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.
What
verify_or_challengecaught exceptions fromintent.verify(credential, request)only to emitpayment_failedand thenKernel.raise— the only failure path in this function that re-raises instead of returning a fresh challenge vianew_challenge.call. Every other failure case (challenge id mismatch, binding mismatch, expired challenge, request mismatch, etc.) already returnsnew_challenge.call(credential, error, echo), producing a retryable 402. A method verification failure — a typedPaymentError(declined, insufficient funds) or an unexpected error — escaped instead.Flagged by the cross-SDK audit as AGR-2026-089. Canonical mppx's
createMethodFnwraps method verification the same way every other failure path here already does. This is the same gap I already fixed instripe/mpp-java'sVerify.java(#26).Fix
Replace the rescue block's manual
emit_payment_failed+Kernel.raisewithreturn new_challenge.call(credential, e, echo).new_challenge.callalready emitspayment_failedinternally when passed a non-nil error (see its own definition earlier in the file), so the manualemit_payment_failedcall is now redundant — removed rather than left as a duplicate emission.Testing
Adds three regression tests in
test/mpp/test_server.rb, using a newThrowingIntenttest double (mirrors the existingMockIntent):VerificationFailedErrorfromintent.verifyreturns a freshMpp::Challengeinstead of raising.RuntimeError(not a typedPaymentError) also returns a fresh challenge rather than escaping uncaught — the "unexpected error" half of the fix.payment_failedfires exactly once (not twice) for a verify failure, confirming the old manual emit call was removed rather than duplicated alongsidenew_challenge.call's own emission.I couldn't run the test suite in my sandbox — no access to rubygems.org to install bundler/minitest — but
ruby -cconfirms both files parse cleanly. Please runbundle exec rake testbefore merging, happy to fix anything that doesn't match.Fixes tempoxyz/mpp-tools#211