Skip to content

fix(env): accept missing/empty NEXT_PUBLIC_VF_DEMO_MODE#175

Merged
TerrifiedBug merged 1 commit intomainfrom
fix/env-demo-mode-empty
Apr 26, 2026
Merged

fix(env): accept missing/empty NEXT_PUBLIC_VF_DEMO_MODE#175
TerrifiedBug merged 1 commit intomainfrom
fix/env-demo-mode-empty

Conversation

@TerrifiedBug
Copy link
Copy Markdown
Owner

Summary

Main CI failed after PR #174 merged: https://github.com/TerrifiedBug/vectorflow/actions/runs/24943042057

The Edge bundling fix worked (process.cwd warnings are now warnings, not errors), but a separate validation failure surfaced underneath:

```
Error: Environment validation failed:

  • NEXT_PUBLIC_VF_DEMO_MODE: Invalid option: expected one of "true"|"false"
    ```

Cause

The Dockerfile declares `ARG NEXT_PUBLIC_VF_DEMO_MODE` with no default. When the GHCR image build runs without `--build-arg NEXT_PUBLIC_VF_DEMO_MODE=...`, the ARG resolves to the empty string. The Zod schema was `z.enum(["true", "false"]).default("false")`, and `.default()` only fires for `undefined` — not `""`. Empty string failed the enum check and crashed the build.

Fix

Relax the schema to accept any string (or undefined) and treat anything other than the literal `"true"` as false:

```typescript
NEXT_PUBLIC_VF_DEMO_MODE: z
.string()
.optional()
.transform((v) => v === "true"),
```

Same runtime semantics: only `"true"` enables demo mode. But missing, empty, or any other value resolves cleanly to `false` instead of throwing.

Test plan

  • Local `pnpm build` passes
  • Local `pnpm test` passes (2526 tests)
  • CI green

@github-actions github-actions Bot added the fix label Apr 26, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 26, 2026

Greptile Summary

This PR fixes a CI build failure introduced by the empty-string edge case in the Zod schema for NEXT_PUBLIC_VF_DEMO_MODE. The previous z.enum(["true","false"]).default("false") schema crashed when the Docker ARG resolved to "" because .default() only substitutes for undefined, not "". The new z.string().optional().transform(v => v === "true") schema correctly maps undefined, "", and any non-"true" value to false, preserving identical runtime semantics while eliminating the crash.

Confidence Score: 5/5

Safe to merge — one-line schema fix with correct semantics, no regressions.

The change is minimal and correct. All relevant input values (undefined, "", "true", "false", anything else) are handled as expected. The output type remains boolean, so no consumers are affected. No security, logic, or correctness issues found.

No files require special attention.

Important Files Changed

Filename Overview
src/lib/env.ts Relaxes NEXT_PUBLIC_VF_DEMO_MODE validation from z.enum(["true","false"]).default("false") to z.string().optional().transform(v => v === "true"), correctly handling undefined and empty-string build-args while preserving boolean semantics for consumers.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Docker ARG NEXT_PUBLIC_VF_DEMO_MODE] --> B{Value?}
    B -->|"true"| C[v === "true" → true]
    B -->|"" empty string| D[v === "true" → false]
    B -->|undefined / unset| E[v === "true" → false]
    B -->|"false" or other| F[v === "true" → false]
    C --> G[env.NEXT_PUBLIC_VF_DEMO_MODE: boolean]
    D --> G
    E --> G
    F --> G
Loading

Reviews (1): Last reviewed commit: "fix(env): accept missing/empty NEXT_PUBL..." | Re-trigger Greptile

@TerrifiedBug TerrifiedBug merged commit f35d76b into main Apr 26, 2026
8 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/env-demo-mode-empty branch April 26, 2026 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant