{"record":{"id":"38aad68b85c71214","repo":"withastro/astro","slug":"expectedimageoptions-38aad6","errorCode":"ExpectedImageOptions","errorMessage":"**${context.collection}** entry is missing an ID.\nInvalid data type: ${typeof data}","messagePattern":"\\*\\*(.+?)\\*\\* entry is missing an ID\\.\nInvalid data type: (.+?)","errorType":"error_code","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/content-layer.ts","lineNumber":534,"sourceCode":"\t\treturn;\n\t}\n\tif (typeof data === 'object') {\n\t\tfor (const [id, raw] of Object.entries(data)) {\n\t\t\tif (raw.id && raw.id !== id) {\n\t\t\t\tthrow new AstroError({\n\t\t\t\t\t...AstroErrorData.ContentLoaderInvalidDataError,\n\t\t\t\t\tmessage: AstroErrorData.ContentLoaderInvalidDataError.message(\n\t\t\t\t\t\tcontext.collection,\n\t\t\t\t\t\t`Object key ${JSON.stringify(id)} does not match ID ${JSON.stringify(raw.id)}`,\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst item = await context.parseData({ id, data: raw });\n\t\t\tcontext.store.set({ id, data: item });\n\t\t}\n\t\treturn;\n\t}\n\tthrow new AstroError({\n\t\t...AstroErrorData.ExpectedImageOptions,\n\t\tmessage: AstroErrorData.ContentLoaderInvalidDataError.message(\n\t\t\tcontext.collection,\n\t\t\t`Invalid data type: ${typeof data}`,\n\t\t),\n\t});\n}\n","sourceCodeStart":516,"sourceCodeEnd":542,"githubUrl":"https://github.com/withastro/astro/blob/52e6c34790cc8ac4e69e6135ace06049867e5c4a/packages/astro/src/content/content-layer.ts#L516-L542","documentation":"A defensive branch at the end of Astro's function-style loader handling: after the zod union (array | record) validates successfully, the data must be an array or an object; anything else falls through to this throw. In practice it is unreachable because the schema only lets arrays and objects through. Note the throw spreads `ExpectedImageOptions` while formatting the message from ContentLoaderInvalidDataError — the error code is wrong, so if you do hit this, report it as an Astro bug.","triggerScenarios":"Not reachable through the public API: loaderReturnSchema would already have rejected non-array/non-object data with ContentLoaderReturnsInvalidId. Only exotic cases (a custom zod setup or an Astro regression) could land here.","commonSituations":"Essentially none; appears only for Astro-internal bugs or patched/modified zod behavior.","solutions":["Ensure your function-style loader returns a plain array or plain object (this error should never fire if error 80's validation passed).","If you can reproduce it, file an Astro issue — both the unreachable branch and the misattributed ExpectedImageOptions code are worth reporting."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function isLoaderReturnable(v: unknown): boolean {\n  return Array.isArray(v) || (v !== null && typeof v === 'object');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await getCollection('blog');\n} catch (err) {\n  // Note: this throw carries the ExpectedImageOptions code but a ContentLoaderInvalidDataError message\n  if (/Invalid data type/.test((err as any).message)) {\n    console.error('Loader returned neither array nor object');\n  } else throw err;\n}","preventionTips":["Return only plain arrays or plain objects from function-style loaders.","If this fires with normal data, report an Astro bug — the branch is unreachable by design and the error code is misattributed."],"tags":["content-collections","content-layer","loader","edge-case"],"backgroundTag":"content-loader-schema-validation","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"}