Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validate regions exist for shipping option price update #9364

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

srindom
Copy link
Collaborator

@srindom srindom commented Sep 28, 2024

What

  • Adds a step to updateShippingOptionsWorkflow and createShippingOptionsWorkflow that validates if the region prices being updated have corresponding regions configured.

Why

  • Previously, if you tried to send a region price update for a region that had been deleted the backend would throw an error when attempting to insert the region price. The error comes from a not-null constraint in the db, but it is better to validate that the regions we are trying to create prices for exist.

Fixes CC-542

Copy link

vercel bot commented Sep 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 28, 2024 4:46pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Sep 28, 2024 4:46pm
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 4:46pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 4:46pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 4:46pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 4:46pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Sep 28, 2024 4:46pm

Copy link

changeset-bot bot commented Sep 28, 2024

⚠️ No Changeset found

Latest commit: a1fdea0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@srindom srindom marked this pull request as ready for review September 28, 2024 16:18
@srindom srindom requested a review from a team as a code owner September 28, 2024 16:18
ContainerRegistrationKeys.REMOTE_QUERY
)

let remoteQueryObject = remoteQueryObjectFromString({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: nothing to do but should we start using the query graph api instead when writing new things?

if (!option.prices) {
return []
}
return option.prices
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sug: return option.prices ?? []

})

const regionService = container.resolve(Modules.REGION)
const regionList = await regionService.listRegions({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sug: we should probably check the length before calling the service just as a best practice, i think we are handling it under the hood but if a module is replaced it might not always be the case wdyt? Also, it removes a call to the service and we can return early if there is nothing to check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants