{"record":{"id":"c8986241aeddde7d","repo":"withastro/astro","slug":"invalidgetstaticpathsreturn","errorCode":"InvalidGetStaticPathsReturn","errorMessage":"Invalid type returned by `getStaticPaths()`. Expected an `array`, got `${typeof result}`.","messagePattern":"Invalid type returned by `getStaticPaths\\(\\)`\\. Expected an `array`, got `(.+?)`\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/routing/validation.ts","lineNumber":28,"sourceCode":"\t\tssr,\n\t\troute,\n\t}: {\n\t\tssr: boolean;\n\t\troute: RouteData;\n\t},\n) {\n\tif ((!ssr || route.prerender) && route.origin !== 'internal' && !mod.getStaticPaths) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.GetStaticPathsRequired,\n\t\t\tlocation: { file: route.component },\n\t\t});\n\t}\n}\n\n/** Throw error and log warnings for malformed getStaticPaths() response */\nexport function validateGetStaticPathsResult(result: GetStaticPathsResult, route: RouteData) {\n\tif (!Array.isArray(result)) {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.InvalidGetStaticPathsReturn,\n\t\t\tmessage: AstroErrorData.InvalidGetStaticPathsReturn.message(typeof result),\n\t\t\tlocation: {\n\t\t\t\tfile: route.component,\n\t\t\t},\n\t\t});\n\t}\n\n\tresult.forEach((pathObject) => {\n\t\tif ((typeof pathObject === 'object' && Array.isArray(pathObject)) || pathObject === null) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.InvalidGetStaticPathsEntry,\n\t\t\t\tmessage: AstroErrorData.InvalidGetStaticPathsEntry.message(\n\t\t\t\t\tArray.isArray(pathObject) ? 'array' : typeof pathObject,\n\t\t\t\t),\n\t\t\t});\n\t\t}\n","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/routing/validation.ts#L10-L46","documentation":"getStaticPaths() must return an array of objects. validateGetStaticPathsResult throws AstroError code InvalidGetStaticPathsReturn when the return value fails Array.isArray. The reported type is the JS typeof of the returned value.","triggerScenarios":"Returning a single object { params: {...} } instead of an array; returning undefined (e.g. forgetting to return from an async function); returning a Promise that resolves to a non-array; returning a Map or other non-array.","commonSituations":"Early return that drops the array; refactoring getStaticPaths and leaving a bare object; awaiting a single entry instead of a list.","solutions":["Ensure the function ends with `return [...]` wrapping every entry in an array.","If you build entries with .map inside .map, flatten the result with .flat() or use .flatMap().","Verify with a quick Array.isArray check before returning."],"exampleFix":"// before\nexport async function getStaticPaths() {\n  return { params: { id: '1' } };\n}\n// after\nexport async function getStaticPaths() {\n  return [{ params: { id: '1' } }];\n}","handlingStrategy":"type-guard","validationCode":"function assertGSPArray(fn) {\n  const result = typeof fn === 'function' ? fn() : fn;\n  if (!Array.isArray(result)) {\n    throw new TypeError(`getStaticPaths must return an array, got ${typeof result}`);\n  }\n  return result;\n}","typeGuard":"const isGSPResult = (r: unknown): r is Array<Record<string, unknown>> =>\n  Array.isArray(r);","tryCatchPattern":null,"preventionTips":["Always wrap entries in an array literal: return [...].","Add a unit test asserting Array.isArray on getStaticPaths output.","Use flatMap when mapping nested sources."],"tags":["getstaticpaths","routing","build"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}