Skip to content

fix(db): correct misleading error message when DATABASE_REPLICA_URL is malformed#5023

Merged
waleedlatif1 merged 94 commits into
simstudioai:stagingfrom
salarkhannn:fix/misleading-db-replica-error-message
Jun 13, 2026
Merged

fix(db): correct misleading error message when DATABASE_REPLICA_URL is malformed#5023
waleedlatif1 merged 94 commits into
simstudioai:stagingfrom
salarkhannn:fix/misleading-db-replica-error-message

Conversation

@salarkhannn

Copy link
Copy Markdown

The error message claimed reads fall back to the primary when DATABASE_REPLICA_URL is unset, but this only applies when the variable is absent entirely. When the variable is set to an invalid value, the code throws a fatal error — there is no graceful fallback. The misleading parenthetical contradicted the actual behavior and could misdirect operators debugging a configuration issue during an incident.

waleedlatif1 and others added 30 commits April 3, 2026 23:30
…ership workflow edits via sockets, ui improvements
…ration, signup method feature flags, SSO improvements
* feat(posthog): Add tracking on mothership abort (simstudioai#4023)

Co-authored-by: Theodore Li <theo@sim.ai>

* fix(login): fix captcha headers for manual login  (simstudioai#4025)

* fix(signup): fix turnstile key loading

* fix(login): fix captcha header passing

* Catch user already exists, remove login form captcha
…nts, secrets performance, polling refactors, drag resources in mothership
…endar triggers, docs updates, integrations/models pages improvements
…mat, logs performance improvements

fix(csp): add missing analytics domains, remove unsafe-eval, fix workspace CSP gap (simstudioai#4179)
fix(landing): return 404 for invalid dynamic route slugs (simstudioai#4182)
improvement(seo): optimize sitemaps, robots.txt, and core web vitals across sim and docs (simstudioai#4170)
fix(gemini): support structured output with tools on Gemini 3 models (simstudioai#4184)
feat(brightdata): add Bright Data integration with 8 tools (simstudioai#4183)
fix(mothership): fix superagent credentials (simstudioai#4185)
fix(logs): close sidebar when selected log disappears from filtered list; cleanup (simstudioai#4186)
v0.6.46: mothership streaming fixes, brightdata integration
waleedlatif1 and others added 25 commits May 20, 2026 23:41
…oogle slides endpoints, DB access pattern improvements
…er, search & replace UX, kb connectors multi-select, mcp negative cache
…ter, hosted-key queueing

v0.6.92: enrichment table column type, table run fixes, scheduled jitter, hosted-key queueing
… messages table, user stats hot path improvements, RB2B
v0.6.95: data enrichment block, nullable workflow description fix
…ables UI improvements, new slack scopes, model-level denylists, object storage tracespans
…ion, together AI, Baseten, Ollama Cloud, Linq integrations, kb doc ownership bindings
…dgebase connector, SSO provider ID allowlist, singleton memory leak fix
…ration, smooth streaming, security hardening, db fixes
…x, db migrations from ci, docs updates, read replicas

v0.7.3: jira oauth scope fix, read-replica client, table wire data fix, db migrations from ci, docs updates, read replicas
…uting, trigger.dev, temporal, latex, quartr, brex, convex integrations
…s malformed

The error message said reads fall back to the primary when unset, but the
code throws a fatal error instead. The misleading parenthetical contradicted
actual behavior and could waste time during incident response when an operator
sees this message and expects graceful degradation.
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@salarkhannn is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

@cursor

cursor Bot commented Jun 13, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
String-only change to a startup validation error message; no runtime logic or connection behavior changes.

Overview
Updates the thrown error when DATABASE_REPLICA_URL is present but not a valid postgres:// / postgresql:// DSN.

The message no longer implies that reads fall back to the primary when the variable is unset—that fallback only applies when the env var is absent. When it is set to a bad value, startup still fails; the text now tells operators to fix the URL or unset the variable instead of pointing at unset behavior.

Reviewed by Cursor Bugbot for commit 4027930. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR corrects a misleading error message in packages/db/db.ts. The old message implied that reads fall back to the primary when DATABASE_REPLICA_URL is unset, but that fallback only applies when the variable is absent entirely — not when it holds an invalid value. When the URL is set but malformed, the code throws a fatal error with no fallback, so the parenthetical actively misdirected operators during incident debugging.

  • The new message (fix the URL or unset the variable) accurately reflects the two available remediation paths without implying a graceful fallback that doesn't exist in this code path.
  • The JSDoc comment at line 28–29, which correctly documents the designed absent-URL fallback behavior, is unchanged and remains accurate.

Confidence Score: 5/5

The change touches only a string literal inside an error-throw branch that is already exercised solely when startup validation fails. No runtime logic, schema, or data path is altered.

The edit replaces one error message string with a more accurate one. The validation condition, the throw, and every code path around it are left untouched. The corrected wording removes a clause that contradicted actual behavior, making the message a faithful description of what operators must do to recover.

No files require special attention.

Important Files Changed

Filename Overview
packages/db/db.ts Single-line error message correction: removes the misleading "(reads fall back to the primary when unset)" parenthetical from the malformed-URL error path, where no fallback actually occurs.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Module loads] --> B{DATABASE_REPLICA_URL set?}
    B -- No / undefined --> C[dbReplica = db primary\nsilent fallback]
    B -- Yes --> D{Matches postgres:// DSN?}
    D -- No --> E[throw Error\n'fix the URL or unset the variable'\nno fallback]
    D -- Yes --> F[dbReplica = drizzle replica client]
Loading

Reviews (1): Last reviewed commit: "fix(db): correct misleading error messag..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 changed the base branch from main to staging June 13, 2026 16:18
@waleedlatif1 waleedlatif1 merged commit 51733b8 into simstudioai:staging Jun 13, 2026
8 of 9 checks passed
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.

5 participants