Skip to content

test: add test case to reproduce REDIS_URL config inconsistency bug (#14962)#14978

Open
yangbobo2021 wants to merge 1 commit intomedusajs:developfrom
yangbobo2021:fix/issue-14962-redis-url-config
Open

test: add test case to reproduce REDIS_URL config inconsistency bug (#14962)#14978
yangbobo2021 wants to merge 1 commit intomedusajs:developfrom
yangbobo2021:fix/issue-14962-redis-url-config

Conversation

@yangbobo2021
Copy link
Copy Markdown

Summary

What — Add test case to reproduce the inconsistency between CLI behavior and defineConfig() regarding REDIS_URL.

Why — The CLI adds REDIS_URL to the .env file when creating a new project, but the defineConfig() function does not automatically read REDIS_URL in non-cloud mode. This creates confusion as users expect the configuration to work automatically.

How — Added a unit test define-config.issue-14962.spec.ts that simulates the default medusa-config.ts template with REDIS_URL set in the environment, and verifies that redisUrl remains undefined in the config.

Testing — Run the test to verify the bug:

```bash
cd packages/core/utils
npx jest src/common/tests/define-config.issue-14962.spec.ts
```


Root Cause

The issue is in packages/core/utils/src/common/define-config.ts:417:

```typescript
...(isCloud ? { redisUrl: process.env.REDIS_URL } : {}),
```

The REDIS_URL is only read when isCloud is true. For regular projects, it's ignored.


Suggested Fix

Option A: Make defineConfig() always read REDIS_URL (recommended)

```typescript
redisUrl: process.env.REDIS_URL,
```

Option B: Remove REDIS_URL from CLI's .env template


Related Issue: #14962


Would you like me to submit a separate PR with the fix for this issue?

…issue-14962)

This test reproduces the inconsistency where the CLI adds REDIS_URL to .env
but defineConfig() does not automatically read it in non-cloud mode.

The test simulates the default medusa-config.ts template and verifies that
redisUrl is undefined even when REDIS_URL is set in the environment.

Related Issue: medusajs#14962
@yangbobo2021 yangbobo2021 requested a review from a team as a code owner March 31, 2026 06:21
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

⚠️ No Changeset found

Latest commit: 8e80cff

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

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

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

A member of the Team first needs to authorize it.

@medusa-os-bot
Copy link
Copy Markdown

medusa-os-bot bot commented Apr 9, 2026

Thank you for your contribution!

After reviewing this PR, we need a few things addressed before we can move forward:

Required changes:

  • Add the test case to the existing packages/core/utils/src/common/__tests__/define-config.spec.ts file instead of creating a new file. Issue-numbered file names (define-config.issue-14962.spec.ts) are not a convention we follow — tests should be discoverable by behaviour, not by ticket reference.
  • Use a closing keyword to link the issue so it gets automatically closed when merged. Change Related Issue: #14962 in the PR body to Closes #14962 (or Fixes #14962).

Notes:

The test itself correctly reproduces the bug — the approach of verifying redisUrl is undefined when REDIS_URL is set in a non-cloud context is accurate. The test logic just needs to live in the right place.

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.

1 participant