{"record":{"id":"3ccd35e36cd4347b","repo":"sveltejs/kit","slug":"invalid-param-definition","errorCode":null,"errorMessage":"Invalid param definition","messagePattern":"Invalid param definition","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/exports/params/index.js","lineNumber":69,"sourceCode":"\t\t\t/** @type {unknown} */ ({\n\t\t\t\t'~standard': {\n\t\t\t\t\tvalidate(/** @type {unknown} */ value) {\n\t\t\t\t\t\tconst result = definition(/** @type {string} */ (value));\n\n\t\t\t\t\t\tif (result === undefined) {\n\t\t\t\t\t\t\treturn { issues: [{ message: 'Invalid param' }] };\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (/** @type {any} */ (result) instanceof Promise) return result; // will be validated and rejected upstream\n\n\t\t\t\t\t\treturn { value: result };\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t})\n\t\t);\n\t}\n\n\tthrow new Error('Invalid param definition');\n}\n","sourceCodeStart":51,"sourceCodeEnd":71,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/exports/params/index.js#L51-L71","documentation":"`normalize_param_definition` parses parameter definitions used by SvelteKit's param-matching API. When the definition string cannot be tokenized/normalized into a valid structure, this generic error is thrown, usually meaning the parameter syntax (modifiers, types, matchers like `[name=int]` or `[name=matcher]`) is malformed.","triggerScenarios":"Malformed bracket syntax in route param definitions — e.g. unmatched brackets, empty param names, unknown modifiers, or invalid matcher references when using `defineParams`/custom param normalization.","commonSituations":"Typo in a route like `/blog/[id` (missing `]`); referencing a matcher file that doesn't exist or has a bad name; hand-writing param definitions programmatically with incorrect interpolation.","solutions":["Fix the param definition syntax: parameters must look like `[name]`, `[name=matcher]`, with valid optional/remainder modifiers (`[name]` vs `[[name]]`, `[...rest]`).","Ensure any referenced matcher exists as a named export in `src/params/<matcher>.js`.","Log/print the definition string passed to `normalize_param_definition` to spot the malformed input.","Validate dynamically-built definitions before use with a regex like /^\\[+\\.{0,3}[a-zA-Z_][a-zA-Z0-9_]*(=[a-zA-Z0-9_-]+)?\\+?\\]$/.","If using `defineParams`, check each definition entry individually to isolate the failing one."],"exampleFix":"// before\nconst def = `[id=${matcherName}`; // missing closing bracket\nnormalize_param_definition(def);\n// after\nconst def = `[id=${matcherName}]`;\nnormalize_param_definition(def);","handlingStrategy":"validation","validationCode":"const PARAM_RE = /^\\[{1,2}(?:\\.\\.\\.)?[a-zA-Z_][a-zA-Z0-9_]*(?:=[a-zA-Z0-9_-]+)?\\]{1,2}$/;\nfunction isValidParamDefinition(def) {\n  return PARAM_RE.test(def);\n}\nif (!isValidParamDefinition(def)) console.error('bad param definition:', def);","typeGuard":null,"tryCatchPattern":"try {\n  normalize_param_definition(def);\n} catch (e) {\n  if (e.message === 'Invalid param definition') {\n    throw new Error(`Malformed param definition \"${def}\" — check brackets, name, and matcher`);\n  }\n  throw e;\n}","preventionTips":["Validate param strings against a strict regex before normalization.","Ensure referenced matchers exist in src/params/.","Escape or validate interpolated values when building definitions dynamically."],"tags":["routing","params","syntax","sveltekit"],"backgroundTag":"invalid-param-definition","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}