sveltejs/kit · warning
The properties of `form.fields` are virtual, so operators li
Error message
The properties of `form.fields` are virtual, so operators like `in` and `Object.keys` are meaningless. If you need the current value of a form field, use `form.fields.x.value()`
What it means
In dev mode, SvelteKit's `form.fields` object is a Proxy whose properties are created lazily on access; there is nothing to enumerate, so `in`, `Object.keys`, spread enumeration, etc. are meaningless against it. The library installs a `has`/`ownKeys` trap that emits this warning to stop developers from writing broken reflection code. Read individual fields directly instead.
Source
Thrown at packages/kit/src/runtime/form-utils.js:699
clone[key] = deep_clone(value[key]);
}
return clone;
}
return value;
}
const warned_sites = new Set();
// keyed by the stack, so every place that enumerates warns once with its call site
const warn_no_keys = () => {
const error = new Error(
'The properties of `form.fields` are virtual, so operators like `in` and `Object.keys` are meaningless. If you need the current value of a form field, use `form.fields.x.value()`'
);
if (warned_sites.has(error.stack)) return;
warned_sites.add(error.stack);
console.warn(error);
};
// fields are created as they are accessed, so there is nothing to enumerate
/** @type {ProxyHandler<object> | null} */
const dev_traps = DEV
? {
has(target, prop) {
if (typeof prop !== 'symbol') warn_no_keys();
return prop in target;
},
ownKeys(target) {
warn_no_keys();
return Reflect.ownKeys(target);
}
}
: null;
/** @param {InternalRemoteFormIssue} issue */View on GitHub (pinned to 03f1687fe6)
Solutions
- Access each field explicitly, e.g. `form.fields.email.value()`, instead of enumerating
- Keep a server-side schema (e.g. a zod schema) and iterate the schema keys rather than `form.fields`
- If enumeration is truly required, gate the code behind a known field list constant
Example fix
// before
for (const name of Object.keys(form.fields)) {
console.log(form.fields[name].value());
}
// after
for (const name of ['email', 'password']) {
console.log(form.fields[name].value());
} Defensive patterns
Strategy: validation
Validate before calling
const FIELD_NAMES = ['email', 'password'];
function isEnumerableFields(fields) {
return fields !== null && typeof fields === 'object' && !Object.keys(fields).length;
}
if (form && isEnumerableFields(form.fields)) {
for (const name of FIELD_NAMES) console.log(form.fields[name]?.value());
} Prevention
- Never use Object.keys/in/spread on form.fields in dev code
- Maintain a static list of field names from your schema
- Read values only via form.fields.x.value()
When it happens
Trigger: Running `Object.keys(form.fields)`, `'x' in form.fields`, `Object.entries(form.fields)`, or similar enumeration on `form.fields` in a +page.svelte load/component during dev, for a form submitted to a non-enhanced action (fields are virtualized because fields only exist once accessed).
Common situations: Iterating all form fields generically to render errors; writing a generic `<input>` loop from `form.fields`; copying form state via spread; SSR/CSR hydration of forms without use:enhance.
Related errors
- The form action returned an error, but +error.svelte wasn't
- The ${protocol_header} header specified ${protocol} which is
- Could not determine host from the ${host_header ? `${host_he
- The ${port_header} header specified ${port} which is an inva
- Address header was specified with ${env_prefix}ADDRESS_HEADE
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/5992c7a8870ecc52.
Report an issue: GitHub.