You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
402 challenge/re-challenge responses now return an RFC 9457 application/problem+json body typed by the failure (malformed-credential, verification-failed, etc.), instead of generic application/json {"error":...}.
One issue to fix before merging: the new axum path converts verification failures with .map_err(MppError::from) before rendering the application/problem+json body, for both Tempo verification and Stripe verification. The extractor then carries that converted error into PaymentRequired::with_error(...) and uses it for the 402 problem response here.
That conversion currently collapses several typed VerificationError codes into MppError::VerificationFailed in the catch-all arm here, even though those codes already declare more specific spec mappings such as malformed-credential, payment-insufficient, and method-unsupportedhere. Once collapsed, MppError::to_problem_details renders them as verification-failedhere, so failures that already have typed codes lose the specific problem type this PR is trying to expose.
Concrete examples: CredentialMismatch from route replay / HMAC checks should map to malformed-credential, InvalidAmount should map to payment-insufficient, and ChainIdMismatch should map to method-unsupported per ErrorCode::spec_code().
Suggested fix: align impl From<VerificationError> for MppError with ErrorCode::spec_code() (or render VerificationError directly without lossy conversion). For example, map CredentialMismatch | InvalidCredential | InvalidPayload to malformed credential, InvalidAmount | InsufficientBalance to payment insufficient, ChainIdMismatch to method unsupported, Expired to payment expired, and keep only the generic verification cases as VerificationFailed. I’d also add an axum regression test that replays a credential across routes / amounts and asserts the 402 problem type is the expected specific URI rather than verification-failed.
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
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.
402 challenge/re-challenge responses now return an RFC 9457
application/problem+jsonbody typed by the failure (malformed-credential,verification-failed, etc.), instead of genericapplication/json {"error":...}.Breaking Change:
ChallengeContext.error:Option<&str>→Option<&MppError>PaymentRequired: tuple → struct{ challenge, error }(usenew/with_error)ChargeChallenger::{challenge,verify_payment,verify_payment_for_amount}returnMppErrornotStringOnly affects code that hand-implements
Transport/ChargeChallengeror parses the old 402 body. Tower middleware unchanged.