{"record":{"id":"5992c7a8870ecc52","repo":"sveltejs/kit","slug":"the-properties-of-form-fields-are-virtual-so-op","errorCode":null,"errorMessage":"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()`","messagePattern":"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\\(\\)`","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/kit/src/runtime/form-utils.js","lineNumber":699,"sourceCode":"\t\t\tclone[key] = deep_clone(value[key]);\n\t\t}\n\n\t\treturn clone;\n\t}\n\n\treturn value;\n}\n\nconst warned_sites = new Set();\n\n// keyed by the stack, so every place that enumerates warns once with its call site\nconst warn_no_keys = () => {\n\tconst error = new Error(\n\t\t'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()`'\n\t);\n\tif (warned_sites.has(error.stack)) return;\n\twarned_sites.add(error.stack);\n\tconsole.warn(error);\n};\n\n// fields are created as they are accessed, so there is nothing to enumerate\n/** @type {ProxyHandler<object> | null} */\nconst dev_traps = DEV\n\t? {\n\t\t\thas(target, prop) {\n\t\t\t\tif (typeof prop !== 'symbol') warn_no_keys();\n\t\t\t\treturn prop in target;\n\t\t\t},\n\t\t\townKeys(target) {\n\t\t\t\twarn_no_keys();\n\t\t\t\treturn Reflect.ownKeys(target);\n\t\t\t}\n\t\t}\n\t: null;\n\n/** @param {InternalRemoteFormIssue} issue */","sourceCodeStart":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/form-utils.js#L681-L717","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nfor (const name of Object.keys(form.fields)) {\n  console.log(form.fields[name].value());\n}\n// after\nfor (const name of ['email', 'password']) {\n  console.log(form.fields[name].value());\n}","handlingStrategy":"validation","validationCode":"const FIELD_NAMES = ['email', 'password'];\nfunction isEnumerableFields(fields) {\n  return fields !== null && typeof fields === 'object' && !Object.keys(fields).length;\n}\nif (form && isEnumerableFields(form.fields)) {\n  for (const name of FIELD_NAMES) console.log(form.fields[name]?.value());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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()"],"tags":["dev-warning","forms","proxy","reactivity"],"backgroundTag":"virtual-proxy-enumeration","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}