Skip to content

fix(ack-pay): preserve original error cause in verifyPaymentRequestToken#65

Open
ak68a wants to merge 1 commit intoagentcommercekit:mainfrom
ak68a:fix/payment-request-error-cause
Open

fix(ack-pay): preserve original error cause in verifyPaymentRequestToken#65
ak68a wants to merge 1 commit intoagentcommercekit:mainfrom
ak68a:fix/payment-request-error-cause

Conversation

@ak68a
Copy link

@ak68a ak68a commented Mar 25, 2026

Summary

  • Preserve the original JWT verification error as an Error Cause when throwing InvalidPaymentRequestTokenError
  • Update the error constructor to accept ErrorOptions

Previously, the catch block discarded the original error (expired token, bad signature, DID resolution failure), making it difficult to diagnose payment request verification failures. The original error is now available via .cause.

Test plan

  • All 32 existing ack-pay tests pass unchanged
  • Error cause is accessible on caught InvalidPaymentRequestTokenError instances

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for payment token verification to preserve underlying error details, improving diagnostics and troubleshooting capabilities.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 25, 2026

Walkthrough

Enhanced error handling in payment request token verification by adding ErrorOptions parameter support to InvalidPaymentRequestTokenError constructor and modifying error catching to preserve the underlying error cause when rethrowing.

Changes

Cohort / File(s) Summary
Error Definition
packages/ack-pay/src/errors.ts
Added optional ErrorOptions parameter to InvalidPaymentRequestTokenError constructor and forwarded it to parent Error class via super(message, options).
Error Handling
packages/ack-pay/src/verify-payment-request-token.ts
Modified catch block to capture the original exception and rethrow InvalidPaymentRequestTokenError with explicit cause preservation using { cause: err }.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preserving the original error cause in verifyPaymentRequestToken error handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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