{"record":{"id":"7346d4bd368b4a6e","repo":"withastro/astro","slug":"getstaticpathsinvalidrouteparam","errorCode":"GetStaticPathsInvalidRouteParam","errorMessage":"Invalid `getStaticPaths()` route parameter for `${key}`. Expected a string or undefined, received `${valueType}` (`${value}`).","messagePattern":"Invalid `getStaticPaths\\(\\)` route parameter for `(.+?)`\\. Expected a string or undefined, received `(.+?)` \\(`(.+?)`\\)\\.","errorType":"validation","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/routing/internal/validation.ts","lineNumber":8,"sourceCode":"import { AstroError, AstroErrorData } from '../../errors/index.js';\n\nconst VALID_PARAM_TYPES = ['string', 'undefined'];\n\n/** Throws error for invalid parameter in getStaticPaths() response */\nexport function validateGetStaticPathsParameter([key, value]: [string, any], route: string) {\n\tif (!VALID_PARAM_TYPES.includes(typeof value)) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.GetStaticPathsInvalidRouteParam,\n\t\t\tmessage: AstroErrorData.GetStaticPathsInvalidRouteParam.message(key, value, typeof value),\n\t\t\tlocation: {\n\t\t\t\tfile: route,\n\t\t\t},\n\t\t});\n\t}\n}\n","sourceCodeStart":1,"sourceCodeEnd":17,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/routing/internal/validation.ts#L1-L17","documentation":"validateGetStaticPathsParameter() rejected a param value whose type is not 'string' or 'undefined'. Because params are encoded into URLs, only strings (and undefined for rest-param emptiness) are allowed. Numbers, booleans, arrays, or objects are rejected with the actual value and its type.","triggerScenarios":"getStaticPaths() returning { params: { id: 123 } } (number), { id: true }, { id: ['a','b'] }, or { id: {} }; passing numeric IDs from a DB without converting to string.","commonSituations":"Returning numeric IDs directly from data sources; spreading arrays into params; booleans from flags; forgetting String() conversion on DB results.","solutions":["Convert every param value to a string: String(value) or template literal `${value}`.","Use undefined (not null) for empty rest params.","Flatten arrays into a single string if a multi-value param is needed."],"exampleFix":"// before\nexport async function getStaticPaths() {\n  return posts.map(p => ({ params: { id: p.id } })); // p.id is a number\n}\n\n// after\nexport async function getStaticPaths() {\n  return posts.map(p => ({ params: { id: String(p.id) } }));\n}","handlingStrategy":"type-guard","validationCode":"function toValidParam(value: unknown): string | undefined {\n  return value === undefined ? undefined : typeof value === 'string' ? value : String(value);\n}\n// normalize before returning from getStaticPaths","typeGuard":"function isValidRouteParamValue(value: unknown): value is string | undefined {\n  return value === undefined || typeof value === 'string';\n}","tryCatchPattern":null,"preventionTips":["Always String() numeric/boolean IDs in getStaticPaths().","Type getStaticPaths params as Record<string, string | undefined>.","Use undefined (not null) for empty rest params."],"tags":["getstaticpaths","validation","routing","typescript"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}