-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(core-flows): update products workflow inexistent properties #13745
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
base: develop
Are you sure you want to change the base?
fix(core-flows): update products workflow inexistent properties #13745
Conversation
🦋 Changeset detectedLatest commit: 4df3c49 The changes in this PR will be included in the next version bump. This PR includes changesets to release 74 packages
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 |
@NicolasGorga is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I havent had time to check just yet. Will do this week
Summary
What — What changes are introduced in this PR?
Normalization step for specific product relations like (category_ids, collection, and tag_ids), before listing products inside of
updateProductsStep
.Why — Why are these changes relevant or necessary?
The product module service already handles this when a product is upserted, by applying this normalization to the payload before executing the update. The problem is that since there is a call to list products, if we pass the payload as is, we would have an error since the Product entity doesn't have a property like
category_ids
as this would be passed as part of the relations config.How — How have these changes been implemented?
Since there was already logic for normalizing these relations inside the product module service
normalizeUpdateProductInput
method, I extracted out the common functionality from this method that I need in theupdateProductsStep
and placed it inside a function in/packages/core/utils/src/products
.In the
createProductsStep
after applying this normalization to the input passed togetSelectsAndRelationsFromObjectArray
the error is resolved, as we reference the correct relation names when listing the products.Testing — How have these changes been tested, or how can the reviewer test the feature?
I searched inside the integration-tests to understand how this slipped by and i see that the
updateProductsWorkflow
is tested through the admin update products api endpoint, which enforces the expected (categories, tags, collection) properties through its validator.I tested this changes locally by calling the workflow directly before applying the fix like:
Which would throw error as described in the linked issue. After applying the fix and running again, it works as expected.
Checklist
Please ensure the following before requesting a review:
yarn changeset
and follow the promptsAdditional Context
I am not quite sure if, although this fixes the issue immediately for users, if we want this long term. The current core api endpoint enforces a non problematic payload as explained before, but this does not match the workflow expected input, which causes confusion IMO.
Instead of updating the types i went with this approach to avoid a breaking change, but let me know what you think. Also, interested to know if there is anywhere i could place a test for this.
Fixes #13708