Skip to content

Conversation

@SGFGOV
Copy link
Contributor

@SGFGOV SGFGOV commented Oct 27, 2025

Summary

errors in the provider authorization step wasn't ever propogated up the stack. Instead the message received was mangled.

Why — Why are these changes relevant or necessary?

Many times there are provider specific error codes and message that need to be visible in other parts of the stack via api etc.

Please provide answer here

It's very simple. We check if the error is a medusaError. This implies the provider has sanitised the error. If it is we allow it to propogate up the stack as it is. Else, we continue with the earlier implementations.

Please provide answer here

Testing — How have these changes been tested, or how can the reviewer test the feature?
You can throw an error in a provider and you should see the same in your api response.


Examples

This isn't really a feature. Just a small bug fix

// this implies the error is already a MedusaError, so we can throw it safely,
      if (e instanceof MedusaError) {
        throw e
      }

Additional Context


Note

Propagates MedusaError from payment authorization and updates integration test to assert cart completion returns cart with payment authorization error.

  • Core Flows (packages/core/core-flows)
    • Payment: In payment/steps/authorize-payment-session.ts, rethrow provider errors when MedusaError.isMedusaError(e) is true to preserve original payment authorization errors.
  • Integration Tests
    • Update integration-tests/modules/__tests__/cart/store/carts.spec.ts to mock authorizePaymentSession throwing MedusaError.Types.PAYMENT_AUTHORIZATION_ERROR and assert /store/carts/:id/complete returns a type: "cart" response with the payment authorization error.
  • Changeset
    • Add patch release for "@medusajs/core-flows".

Written by Cursor Bugbot for commit 098a2d5. This will update automatically on new commits. Configure here.

@SGFGOV SGFGOV requested a review from a team as a code owner October 27, 2025 17:36
@changeset-bot
Copy link

changeset-bot bot commented Oct 27, 2025

🦋 Changeset detected

Latest commit: 098a2d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 74 packages
Name Type
@medusajs/core-flows Patch
@medusajs/medusa Patch
integration-tests-http Patch
@medusajs/test-utils Patch
@medusajs/medusa-oas-cli Patch
@medusajs/analytics Patch
@medusajs/api-key Patch
@medusajs/auth Patch
@medusajs/caching Patch
@medusajs/cart Patch
@medusajs/currency Patch
@medusajs/customer Patch
@medusajs/file Patch
@medusajs/fulfillment Patch
@medusajs/index Patch
@medusajs/inventory Patch
@medusajs/link-modules Patch
@medusajs/locking Patch
@medusajs/notification Patch
@medusajs/order Patch
@medusajs/payment Patch
@medusajs/pricing Patch
@medusajs/product Patch
@medusajs/promotion Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/workflow-engine-redis Patch
@medusajs/draft-order Patch
@medusajs/oas-github-ci Patch
@medusajs/cache-inmemory Patch
@medusajs/cache-redis Patch
@medusajs/event-bus-local Patch
@medusajs/event-bus-redis Patch
@medusajs/analytics-local Patch
@medusajs/analytics-posthog Patch
@medusajs/auth-emailpass Patch
@medusajs/auth-github Patch
@medusajs/auth-google Patch
@medusajs/caching-redis Patch
@medusajs/file-local Patch
@medusajs/file-s3 Patch
@medusajs/fulfillment-manual Patch
@medusajs/locking-postgres Patch
@medusajs/locking-redis Patch
@medusajs/notification-local Patch
@medusajs/notification-sendgrid Patch
@medusajs/payment-stripe Patch
@medusajs/framework Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/telemetry Patch
@medusajs/admin-bundler Patch
@medusajs/admin-sdk Patch
@medusajs/admin-shared Patch
@medusajs/admin-vite-plugin Patch
@medusajs/dashboard Patch
@medusajs/icons Patch
@medusajs/toolbox Patch
@medusajs/ui-preset Patch
create-medusa-app Patch
medusa-dev-cli Patch
@medusajs/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 27, 2025

@SGFGOV is attempting to deploy a commit to the medusajs Team on Vercel.

A member of the Team first needs to authorize it.

@SGFGOV
Copy link
Contributor Author

SGFGOV commented Oct 28, 2025

@olivermrbl , sorry to ping you directly. would you mind reviewing and approving. it's blocking a development activity. We need a method of sending an error message up the stack from the the payment provider. This seemed the simplest way to do so

cursor[bot]

This comment was marked as outdated.

@willbouch willbouch changed the title fix: payment error handling - Patch fix(core-flows): payment error handling Oct 29, 2025
@willbouch
Copy link
Contributor

Hi @SGFGOV ! Can you give a little bit more context as to what is happening? I think the PR makes sense, but I am scared that it might be a breaking change for some people. My reasoning behind this is "what exactly happens with those medusa errors that are "skipped"? You see the error received is mangled? Can you maybe provide an example?

@SGFGOV
Copy link
Contributor Author

SGFGOV commented Oct 29, 2025

When those messages are skipped the old flow continues..so whatever was the older behaviour prior to this PR, that is preserved.

@SGFGOV
Copy link
Contributor Author

SGFGOV commented Oct 30, 2025

@adrien2p thanks for approving. has the been merged into the dev or will it be included in the next release

@SGFGOV
Copy link
Contributor Author

SGFGOV commented Oct 30, 2025

@adrien2p thanks for approving. has the been merged into the dev or will it be included in the next release

Thanks I figured it out :) it's in the changeset

@willbouch
Copy link
Contributor

@SGFGOV It looks like one test is failing. I cannot deploy it without the text fixed :/
CleanShot 2025-10-30 at 08 46 22

@SGFGOV
Copy link
Contributor Author

SGFGOV commented Oct 31, 2025

Ok let me fix it :)

cursor[bot]

This comment was marked as outdated.

@SGFGOV
Copy link
Contributor Author

SGFGOV commented Oct 31, 2025

@willbouch please check and approve

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.

4 participants