Skip to content

fix(env): schema treatment of empty string for redis url#4862

Merged
icecrasher321 merged 1 commit into
stagingfrom
fix/env-schema
Jun 3, 2026
Merged

fix(env): schema treatment of empty string for redis url#4862
icecrasher321 merged 1 commit into
stagingfrom
fix/env-schema

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

Summary

Docker compose injects as empty string which leads to failures if redis not setup.

Type of Change

  • Bug fix

Testing

N/A

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 3, 2026 5:15pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Jun 3, 2026

PR Summary

Low Risk
Small env parsing tweak with no auth or data-path changes; only affects whether Redis adapter is enabled when the variable is empty.

Overview
Treats a blank REDIS_URL (e.g. from Docker Compose when Redis is not configured) as unset before Zod validation, so startup no longer fails URL parsing and the realtime service can run in single-pod mode without Redis.

The change is a z.preprocess on REDIS_URL in apps/realtime/src/env.ts that maps whitespace-only strings to undefined, then applies the existing optional URL schema.

Reviewed by Cursor Bugbot for commit 348ab13. Configure here.

@icecrasher321 icecrasher321 changed the title fix(env): schema treatment of empty string fix(env): schema treatment of empty string for redis url Jun 3, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 3, 2026

Greptile Summary

This PR fixes a validation failure in the realtime app's env schema when Docker Compose injects REDIS_URL as an empty string (its default for unset variables) rather than leaving it absent.

  • REDIS_URL is now wrapped in z.preprocess() to convert empty or whitespace-only strings to undefined before Zod's URL validator runs, preventing a startup crash when Redis is not configured.
  • No other optional URL fields in apps/realtime/src/env.ts require the same treatment (all others are either required or validated as plain strings, not URLs).

Confidence Score: 5/5

Safe to merge — the change is a targeted one-line schema fix with no side effects on other env fields.

The fix is minimal and correct: z.preprocess converts empty/whitespace strings to undefined before the URL validator runs, which is the standard Zod idiom for this pattern. The typeof value === 'string' guard prevents unexpected coercion of non-string inputs. No other fields in this schema are affected.

No files require special attention.

Important Files Changed

Filename Overview
apps/realtime/src/env.ts Wraps REDIS_URL in z.preprocess to coerce empty strings to undefined, fixing Docker Compose startup failures when Redis is not configured.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[process.env.REDIS_URL] --> B{preprocess}
    B -->|empty or whitespace string| C[undefined]
    B -->|non-empty string| D[original value]
    C --> E{url validator - optional}
    D --> E
    E -->|undefined| F[Valid - Redis disabled]
    E -->|valid URL| G[Valid - Redis enabled]
    E -->|invalid URL| H[Validation error thrown]
Loading

Reviews (1): Last reviewed commit: "fix(env): schema treatment of empty stri..." | Re-trigger Greptile

@icecrasher321 icecrasher321 merged commit 1933fc4 into staging Jun 3, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/env-schema branch June 3, 2026 19:25
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.

1 participant