Repository navigation
Commit dca03da
fix(env): pass Object.prototype members through the env proxy (#725)
When `env.ts` registers a schema, reading an `Object.prototype` member
from `env` throws:
```ts
import { env } from 'void/env';
env.hasOwnProperty('STRIPE_KEY');
env.constructor;
String(env);
```
```
TypeError: Cannot read properties of undefined (reading 'validate')
```
`readKey` looks the key up with `registry.schema[key]`, which also finds
inherited members, and treats them as validators. Without a schema, the
same expressions work.
## Fix
`readKey` checks the key with `Object.hasOwn`, so these members pass
through like any key the schema doesn't declare.
## Tests
`packages/void/test/unit/env-schema.test.ts`: the three reads above with
a registered schema. The case fails without this fix.
## Verification
- `vp test run`: 776 files pass, 1 skipped (16,002 tests pass, 29
skipped).
- `vp run check`: 33/33 pass.
- By hand on a copy of `playground/ssr` with an `env.ts`: a route that
makes these reads answers 200 in `vp dev` and `vp preview`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent d4c4b49 commit dca03da
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
| 255 | + | |
| 256 | + | |
256 | 257 | | |
257 | 258 | | |
258 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
130 | 139 | | |
131 | 140 | | |
132 | 141 | | |
| |||
0 commit comments