{"record":{"id":"0b4578f17931c2b1","repo":"sveltejs/kit","slug":"parameter-values-must-be-a-string-number-boolean","errorCode":null,"errorMessage":"Parameter values must be a string, number, boolean, or bigint","messagePattern":"Parameter values must be a string, number, boolean, or bigint","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/utils/routing.js","lineNumber":331,"sourceCode":"\t\t\t\t\tif (typeof value === 'string') {\n\t\t\t\t\t\tif (value.startsWith('/') || value.endsWith('/')) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn value;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value === 'number' ||\n\t\t\t\t\t\ttypeof value === 'boolean' ||\n\t\t\t\t\t\ttypeof value === 'bigint'\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn String(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error('Parameter values must be a string, number, boolean, or bigint');\n\t\t\t\t})\n\t\t\t)\n\t\t\t.filter(Boolean)\n\t\t\t.join('/') +\n\t\t(has_id_trailing_slash ? '/' : '')\n\t);\n}\n\n/**\n * @param {import('types').SSRNode} node\n * @returns {boolean}\n */\nexport function has_server_load(node) {\n\treturn node.server?.load !== undefined || node.server?.trailingSlash !== undefined;\n}\n\n/**\n * Find the first route that matches the given path","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/utils/routing.js#L313-L349","documentation":"`resolve_route` stringifies each parameter into the route path. Only strings, numbers, booleans, and bigints can be safely converted; any other value type (objects, arrays, null, undefined reaching this branch) is rejected with this error to prevent silently rendering `[object Object]` in URLs.","triggerScenarios":"Resolving a route with a params object containing an object/array (e.g. `{ id: { value: 1 } }`), null, or a value type not covered by the earlier branches (and not handled as optional/rest).","commonSituations":"Passing parsed objects (Date, model instances) as params instead of their string/id representation; accidentally wrapping the param in an object; supplying null from failed data lookups.","solutions":["Stringify or otherwise convert the value before resolving (e.g. `String(obj.id)`, `date.toISOString()`)","Ensure lookups that produce params cannot return null/undefined objects for required params","Coerce booleans/numbers deliberately so only intended primitives reach resolution"],"exampleFix":"// before\nresolve_route(id, pattern, { date: new Date('2024-01-01') });\n// after\nresolve_route(id, pattern, { date: '2024-01-01' });","handlingStrategy":"type-guard","validationCode":"function isStringifiableParam(v) {\n\treturn typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || typeof v === 'bigint';\n}\nObject.values(params).forEach((v) => { if (!isStringifiableParam(v)) throw new Error('param not primitive'); });","typeGuard":"function isParamValue(v) {\n\treturn ['string', 'number', 'boolean', 'bigint'].includes(typeof v);\n}","tryCatchPattern":"try {\n\tconst href = resolveRoute(id, pattern, params);\n} catch (e) {\n\tif (e.message.startsWith('Parameter values must be')) {\n\t\t// stringify/serialize the offending param before resolving\n\t}\n\tthrow e;\n}","preventionTips":["Only pass primitives into route resolution","Convert Dates/objects to ids or ISO strings upstream","Guard against null from failed lookups before resolving"],"tags":["routing","params","type-conversion","runtime"],"backgroundTag":"invalid-route-param-type","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}