fix(env): fixed zod error changing to preprocess and coercing includi…#531
fix(env): fixed zod error changing to preprocess and coercing includi…#531SandipGyawali wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
⚠️ APPROVE unavailable on this installation — the maintainer GitHub App does not havepull_requests: writeon OpenRouterTeam. The verdict below is posted as COMMENT. Event-level approval (for branch-protection / review requirements) must be added out-of-band.
Perry's Review
Fixes OPENROUTER_DEBUG=false (and similar falsy strings) incorrectly enabling debug mode. Previously z.coerce.boolean("false") returns true, so the preprocess guard is the right fix. The new test coverage is thorough.
Verdict: ✅ LGTM
Details
Risk: 🟢 Low — debug-logging path only; no auth, payments, or hot paths; fully reversible
CI: no checks present
Findings (see inline comments for full context):
- nit: resetEnv() in beforeEach is a no-op here — tests call envSchema.parse() directly (stateless), not env(), so clearing the memo has no effect. Harmless but slightly misleading.
Codex: skipped (small tier)
Research: skipped (small tier)
Security: no concerns — only affects debug-logging opt-in; no credential handling touched
Test coverage: 120-line test file covering falsy strings (false, 0, off, no, empty), case-insensitive variants, boolean pass-through, and undefined — good blast coverage.
Unresolved threads: 1 outdated Perry thread (prior import suggestion, resolved by this push)
Scope: first review (full)
Review: tier=small · model=claude-sonnet-latest · score=1.7
| OPENROUTER_APP_CATEGORIES: z.string().optional(), | ||
|
|
||
| OPENROUTER_DEBUG: z.coerce.boolean().optional(), | ||
| OPENROUTER_DEBUG: z.preprocess( |
There was a problem hiding this comment.
[suggestion] src/lib/env.ts carries a Code generated by Speakeasy — DO NOT EDIT header — verify this change survives regeneration.
Details
Why: Speakeasy regenerates this file from the OpenAPI spec. With persistentEdits: enabled: "true" in .speakeasy/gen.yaml, Speakeasy will attempt to re-apply manual edits after regeneration, but this is not guaranteed — especially for logic changes inside schema fields. If a Speakeasy upgrade or spec bump triggers full file regeneration, the preprocess guard and tests may silently diverge from the schema.
Options:
- Run
speakeasy runlocally and confirm the preprocess block survives in the regenerated output. - If persistentEdits is unreliable for this pattern, add a Speakeasy overlay (similar to
.speakeasy/overlays/boolean-query-params.overlay.yaml) to make this the generated default.
Prompt for agents
In `src/lib/env.ts` at line 38, the manual `z.preprocess` block for `OPENROUTER_DEBUG` lives inside a Speakeasy-generated file (`DO NOT EDIT` header). Verify that `.speakeasy/gen.yaml`'s `persistentEdits: enabled: "true"` actually preserves this block by running `speakeasy run` locally and confirming the preprocess logic is still present in the regenerated output. If not preserved, either add a `.speakeasy/overlays/` overlay to codify this schema change, or document the manual steps required after each regeneration.
Reviewed at eed9ad8
…ng it's test case and behaviour
Uh oh!
There was an error while loading. Please reload this page.