Skip to content

fix(workflow-engine-redis,core-flows): support top-level redis options and allow adding addresses to orders without existing country code - #16736

Open
vjymisal0 wants to merge 4 commits into
medusajs:developfrom
vjymisal0:fix/workflow-redis-options-and-order-address-guard
Open

fix(workflow-engine-redis,core-flows): support top-level redis options and allow adding addresses to orders without existing country code#16736
vjymisal0 wants to merge 4 commits into
medusajs:developfrom
vjymisal0:fix/workflow-redis-options-and-order-address-guard

Conversation

@vjymisal0

@vjymisal0 vjymisal0 commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What

  • Supports top-level redisUrl and redisOptions in @medusajs/workflow-engine-redis service loader.
  • Fixes order address validation in updateOrderValidationStep (@medusajs/core-flows) to allow adding shipping/billing addresses when an order does not already have an existing country code.

Why

How

  • Updated loader in packages/workflow-engine-redis/src/loaders/index.ts to check both top-level and nested Redis options.
  • Extracted and normalized country code guard logic in packages/core-flows/src/order/steps/update-order-validation.ts to allow new address assignment when prior country code is absent.
  • Added comprehensive unit tests in packages/workflow-engine-redis/src/loaders/__tests__/redis-loader.spec.ts and packages/core-flows/src/order/steps/__tests__/update-order-validation.spec.ts.

Testing

  • Added unit tests for workflow engine redis loader with top-level options.
  • Added unit tests for order address validation with empty previous country code.
  • Added changeset file .changeset/eighty-sheep-burn.md.

…s and allow adding addresses to orders without existing country code (fixes medusajs#16697, medusajs#16636)
@vjymisal0
vjymisal0 requested a review from a team as a code owner September 5, 2026 12:43
@changeset-bot

changeset-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c79fe7e

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

This PR includes changesets to release 83 packages
Name Type
@medusajs/workflow-engine-redis Patch
@medusajs/core-flows Patch
@medusajs/medusa Patch
@medusajs/test-utils Patch
integration-tests-http Patch
@medusajs/loyalty-plugin 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/rbac Patch
@medusajs/region Patch
@medusajs/sales-channel Patch
@medusajs/search Patch
@medusajs/settings Patch
@medusajs/stock-location Patch
@medusajs/store Patch
@medusajs/tax Patch
@medusajs/translation Patch
@medusajs/user Patch
@medusajs/workflow-engine-inmemory Patch
@medusajs/search-postgres 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/auth-oidc 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/instantsearch-adapter Patch
@medusajs/js-sdk Patch
@medusajs/modules-sdk Patch
@medusajs/orchestration Patch
@medusajs/query Patch
@medusajs/types Patch
@medusajs/utils Patch
@medusajs/workflows-sdk Patch
create-medusa-app Patch
@medusajs/http-types-generator Patch
@medusajs/cli Patch
@medusajs/deps Patch
@medusajs/eslint-plugin 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
@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

@medusa-os-bot

medusa-os-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thanks for the contribution! We need more information before reviewing this further.

The PR addresses two separate issues: (1) adding support for top-level redisUrl/options in the workflow-engine-redis loader so that configurations matching the declared types work at runtime without nesting under redis, and (2) fixing a false positive error in updateOrderValidationStep that prevented adding a shipping or billing address to an order that had no existing country code. The implementation extracts a reusable throwIfCountryCodeChanged helper and adjusts the guard to only reject changes when an existing country_code is present. Unit tests are included for both fixes. The PR body does not follow the required template — the What, Why, How, and Testing sections are all absent. Please ask the author to resubmit using the standard PR template before the code is reviewed further. Heads up: PR #16698 (opened 2026-09-02) and PR #16699 (opened 2026-09-02) both reference issue #16697 and were opened earlier than this PR; if either is merged first, this PR may be closed as a duplicate for that fix. Similarly, PR #16637 (opened 2026-08-27), PR #16659 (opened 2026-08-30), and PR #16689 (opened 2026-09-02) reference issue #16636 and were opened earlier.

Triggered by: new PR opened

@medusa-os-bot

medusa-os-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thanks for the contribution! A few items need to be addressed before this can move forward:

The author filled in all four PR template sections (What, Why, How, Testing) since the previous review, so that earlier issue is resolved. The logic in the new throwIfCountryCodeChanged helper is correct and properly fixes the false-positive validation error. The Redis loader fallback is also correct. However, the patch for update-order.ts has a structural error: the line } from "../steps" is marked as a removed line (-) in the diff rather than being kept as context. This closing brace belongs to the import { block at line 23 that imports five named exports from "../steps". After the patch is applied that block is unclosed, producing a TypeScript syntax error that would prevent the file from compiling. The fix is straightforward: keep } from "../steps" as a context line in the patch and only remove the import { throwIfOrderIsCancelled } from "../utils/order-validation" line.

  • packages/core/core-flows/src/order/workflows/update-order.ts: syntax error in patch — the line } from "../steps" (line 29 of the current file, which closes the multi-export import { block beginning at line 23) is marked as removed (-) rather than kept as context. After the patch is applied, the import block for previewOrderChangeStep, registerOrderChangesStep, updateOrderItemsTranslationsStep, updateOrderShippingMethodsTranslationsStep, and updateOrdersStep is left unclosed, which is a TypeScript syntax error and will prevent the file from compiling. Fix: the } from "../steps" line must be a context line (no - prefix) in the patch — only the import { throwIfOrderIsCancelled } from "../utils/order-validation" line should be removed and replaced with the new multi-line import.

Triggered by: new commit pushed

@medusa-os-bot

medusa-os-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thanks for the contribution! A few items need to be addressed before this can move forward:

The author filled in all four PR template sections after the first review, and both fixes are logically sound: the throwIfCountryCodeChanged helper correctly permits adding an address when no country code previously existed, and the Redis loader fallback correctly handles top-level options via options?.redis ?? options. Unit tests are included for both. However, the patch for update-order.ts still contains the same structural error that was flagged in the previous bot review: the } from "../steps" closing brace (line 29 in the base file) is marked as a removed line (-) in the diff rather than kept as context. After the patch is applied the multi-export import block for ../steps is left unclosed, producing a TypeScript syntax error that prevents the file from compiling. The author needs to regenerate the patch so that only the single-line import { throwIfOrderIsCancelled } from "../utils/order-validation" is removed, while } from "../steps" is left as a context (unchanged) line.

  • packages/core/core-flows/src/order/workflows/update-order.ts (around line 29): the diff marks } from "../steps" as a removed line (-), but this line is the closing brace of the multi-export import block that begins at line 23 (import { previewOrderChangeStep, registerOrderChangesStep, ...). Removing it leaves that import block unclosed, which is a TypeScript syntax error. Fix: keep } from "../steps" as a context line in the patch. Only the subsequent line import { throwIfOrderIsCancelled } from "../utils/order-validation" should be removed and replaced with the new multi-line import — the closing brace for ../steps must remain.

Triggered by: PR description updated

@medusa-os-bot

medusa-os-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

Thanks for the contribution! Initial automated review looks good.

The author has resolved the blocking issue flagged in the two previous bot reviews: the } from "../steps" closing brace in update-order.ts is now correctly kept as a context line in the diff rather than being removed. Both fixes are logically sound. The throwIfCountryCodeChanged helper guards on existingAddress?.country_code before comparing values, so it correctly skips the check when no prior country code exists, resolving the false-positive error when adding an address to an order that has none. The Redis loader fallback (options?.redis ?? options) correctly handles top-level redisUrl/redisOptions without the nested redis key. The PR template is fully filled, a changeset with the correct patch bump and fix(...) message is included, and unit tests cover the new helper and the validation step. Notes (non-blocking): - packages/core/core-flows/src/order/workflows/tests/update-order.spec.ts (first it block, line 5): const step = (updateOrderValidationStep as any).step is declared but never used — this is dead code that can be removed.

Triggered by: new commit pushed

@vjymisal0

Copy link
Copy Markdown
Contributor Author

Checked this again. The latest bot review only has a non-blocking note; the syntax issue is already fixed and the changeset/template/tests are in place. Since #16761 covers the same areas plus the fulfillment fix, I’ll leave this one as-is unless maintainers prefer the smaller two-fix PR.

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

Projects

None yet

1 participant