Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/void/src/runtime/env-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ function readKey(key: string): unknown {
if (!registry.schema) {
return rawValue;
}
const validator = registry.schema[key];
// `env.hasOwnProperty` and the like come from Object.prototype, not from the schema.
const validator = Object.hasOwn(registry.schema, key) ? registry.schema[key] : undefined;
if (!validator) {
return rawValue;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/void/test/unit/env-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ describe('defineEnv + env proxy', () => {
});
});

it('passes through Object.prototype members without validation', () => {
defineEnv({ STRIPE_KEY: string() });
withRuntimeEnv({ STRIPE_KEY: 'sk' }, () => {
expect(env.hasOwnProperty).toBe(Object.prototype.hasOwnProperty);
expect(env.constructor).toBe(Object);
expect(String(env)).toBe('[object Object]');
});
});

it('caches validated values per env identity (no re-validation)', () => {
let calls = 0;
const inner = string();
Expand Down