fix(env): accept missing/empty NEXT_PUBLIC_VF_DEMO_MODE#175
fix(env): accept missing/empty NEXT_PUBLIC_VF_DEMO_MODE#175TerrifiedBug merged 1 commit intomainfrom
Conversation
Greptile SummaryThis PR fixes a CI build failure introduced by the empty-string edge case in the Zod schema for Confidence Score: 5/5Safe 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
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
Reviews (1): Last reviewed commit: "fix(env): accept missing/empty NEXT_PUBL..." | Re-trigger Greptile |
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:
```
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