{"record":{"id":"3b250ec6f341705f","repo":"sveltejs/kit","slug":"new-validationerror-result-issues-carries-the-s","errorCode":null,"errorMessage":"new ValidationError(result.issues) — carries the Standard Schema issues array","messagePattern":"new ValidationError\\(result\\.issues\\) — carries the Standard Schema issues array","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/app/server/remote/shared.js","lineNumber":35,"sourceCode":"\t\t\t\terror(400, 'Bad Request');\n\t\t\t}\n\t\t};\n\t}\n\n\t// if 'unchecked', pass input through without validating\n\tif (validate_or_fn === 'unchecked') {\n\t\treturn (arg) => arg;\n\t}\n\n\t// use https://standardschema.dev validator if provided\n\tif ('~standard' in validate_or_fn) {\n\t\treturn async (arg) => {\n\t\t\t// access property and call method in one go to preserve potential this context\n\t\t\tconst result = await validate_or_fn['~standard'].validate(arg);\n\n\t\t\t// if the `issues` field exists, the validation failed\n\t\t\tif (result.issues) {\n\t\t\t\tthrow new ValidationError(result.issues);\n\t\t\t}\n\n\t\t\treturn result.value;\n\t\t};\n\t}\n\n\tthrow new Error(\n\t\t'Invalid validator passed to remote function. Expected \"unchecked\" or a Standard Schema (https://standardschema.dev)'\n\t);\n}\n\n/**\n * In case of a single remote function call, just returns the result.\n *\n * In case of a full page reload, returns the response for a remote function call,\n * either from the cache or by invoking the function.\n * Also saves an uneval'ed version of the result for later HTML inlining for hydration.\n *","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/app/server/remote/shared.js#L17-L53","documentation":"A remote function's argument validator implements Standard Schema; when `validate(arg)` reports `issues`, SvelteKit wraps them in a `ValidationError` and throws. For queries this becomes a 400-style failure returned to the client; for batched `requested()` iterations it surfaces as the 'Skipping ...' wrapper error.","triggerScenarios":"Calling a remote `query`/`command`/`form` declared like `.query(fn, zodSchema)` (or Valibot/ArkType) with an argument that fails the schema — wrong type, missing field, failed refinement.","commonSituations":"Client sends unvalidated form/URL data; schema updated server-side so previously valid clients now fail; `parseInt` yielding `NaN` against a `z.number()`; empty string against a non-empty string schema.","solutions":["Run the same schema client-side (`schema.safeParse`) before calling the remote function to catch issues early.","Loosen or correct the schema so legitimate inputs pass (e.g. coerce: `z.coerce.number()`).","Fix the caller to send data in the shape the schema expects.","Catch the ValidationError server-side and return a friendlier `error(400, ...)` message if needed."],"exampleFix":"// before\nconst result = await updateProfile({ age: form.get('age') }); // '33' as string\n// after\nconst parsed = z.object({ age: z.coerce.number() }).safeParse({ age: form.get('age') });\nif (!parsed.success) showIssues(parsed.error.issues);\nelse await updateProfile(parsed.data);","handlingStrategy":"validation","validationCode":"const parsed = schema.safeParse(arg);\nif (!parsed.success) {\n  // handle issues before calling the remote function\n  throw parsed.error;\n}","typeGuard":"function parseArg(schema, arg) {\n  const r = schema.safeParse(arg);\n  return r.success ? { ok: true, value: r.data } : { ok: false, issues: r.error.issues };\n}","tryCatchPattern":"try {\n  await myQuery(arg);\n} catch (e) {\n  if (e instanceof ValidationError) showIssues(e.issues);\n  else throw e;\n}","preventionTips":["Reuse the exact same schema on the client for pre-flight validation.","Prefer coercing schemas (z.coerce.*) for URL/form string inputs.","Keep schemas in a shared module so server and client never drift.","Schema-check any payload restored from caches or older clients."],"tags":["validation","standard-schema","remote-functions","zod"],"backgroundTag":"schema-validation-failed","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}