Skip to content

Env validation falls back to localhost defaults in non-production, masking misconfiguration #83

Description

@cybermax4200

Why this matters now: A staging/preview deploy with a wrong DATABASE_URL (or missing JWT_SECRET) silently connects to localhost instead of failing fast, hiding outages and secret gaps.

Problem / What: validate.ts:88-118 — when safeParse fails and NODE_ENV !== 'production', it logs a warning and returns a fallback env with DATABASE_URL and JWT_SECRET defaults. So a misconfigured staging instance "starts successfully" against the wrong database and a known dev JWT secret.

Key Challenges: Defining which env vars are mandatory per environment (staging should fail closed on DATABASE_URL/secrets even if not "production"), without breaking local dev convenience.

Acceptance Criteria:

  • A staging deployment missing/incorrect DATABASE_URL or JWT_SECRET fails fast with a clear error.
  • Local development keeps ergonomic defaults (test proves both).

Relevant files/functions: src/config/validate.ts:84-118, src/config/startup.ts, src/config/jwtSecret.ts.

Out of scope: Moving config to a secrets manager.

Labels: advanced, ops, bug

Activity

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignadvancedbugSomething isn't workingops

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions