{"record":{"id":"f02440a212198076","repo":"withastro/astro","slug":"invalidgetstaticpathsentry","errorCode":"InvalidGetStaticPathsEntry","errorMessage":"Invalid entry returned by `getStaticPaths()`. Expected an object, got `${entryType}`.","messagePattern":"Invalid entry returned by `getStaticPaths\\(\\)`\\. Expected an object, got `(.+?)`\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/routing/validation.ts","lineNumber":39,"sourceCode":"\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\n\t\tif (\n\t\t\tpathObject.params === undefined ||\n\t\t\tpathObject.params === null ||\n\t\t\t(pathObject.params && Object.keys(pathObject.params).length === 0)\n\t\t) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.GetStaticPathsExpectedParams,\n\t\t\t\tlocation: {\n\t\t\t\t\tfile: route.component,\n\t\t\t\t},\n\t\t\t});","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/core/routing/validation.ts#L21-L57","documentation":"Every element of the array returned by getStaticPaths() must be an object of the shape { params, props }. validateGetStaticPathsResult iterates the result and throws InvalidGetStaticPathsEntry when an entry is itself an array or null (typeof interpolated into the message). Arrays and null pass an Array.isArray(result) check on the outer value but are not valid entries.","triggerScenarios":"Returning an array of arrays (e.g. a .flatMap() that produced nested arrays); including null entries from a .map() with a conditional return; returning [ ...Object.entries(posts) ] which yields [key, value] pairs; a filter chain that left undefined/null slots.","commonSituations":"Using Object.entries() to convert a keyed map instead of Object.values(); conditional mapping like posts.map(p => p.published && { params: ... }) which yields false/null entries; refactor from a nested-loop structure that kept inner arrays.","solutions":["Flatten/normalize so each entry is one { params, props } object: use Object.values(posts).map(...) instead of Object.entries(posts).","Turn conditional maps into filter().map() so invalid entries never enter the array: posts.filter(p => p.published).map(...).","Use .flatMap() correctly so nested arrays collapse to entry objects."],"exampleFix":"// before\nexport function getStaticPaths() {\n  return posts.map((p) => p.published && { params: { slug: p.slug } }); // false entries\n}\n\n// after\nexport function getStaticPaths() {\n  return posts.filter((p) => p.published).map((p) => ({ params: { slug: p.slug } }));\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"function isEntryObject(v: unknown): v is { params: unknown; props?: unknown } {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n// entries.every(isEntryObject) must hold before returning from getStaticPaths","tryCatchPattern":null,"preventionTips":["Prefer filter().map() over boolean-returning map() so no false/null entries appear.","Object.entries() yields arrays — map to objects explicitly.","Annotate getStaticPaths' return type so the compiler rejects entry arrays/nulls."],"tags":["astro","getstaticpaths","static-generation","validation"],"backgroundTag":"getstaticpaths-validation-failed","analyzedSha":"52e6c34790cc8ac4e69e6135ace06049867e5c4a","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}