{"record":{"id":"ba8cbff90fa8ed59","repo":"withastro/astro","slug":"expectedimage","errorCode":"ExpectedImage","errorMessage":"Expected `src` property for `getImage` or `<Image />` to be either an ESM imported image or a string with the path of a remote image. Received `${src}` (type: `${typeofOptions}`).\\n\\nFull serialized options received: `${fullOptions}`.","messagePattern":"Expected `src` property for `getImage` or `<Image />` to be either an ESM imported image or a string with the path of a remote image\\. Received `(.+?)` \\(type: `(.+?)`\\)\\.\\\\n\\\\nFull serialized options received: `(.+?)`\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/internal.ts","lineNumber":59,"sourceCode":"\t\tglobalThis.astroAsset.imageService = service;\n\t\treturn service;\n\t}\n\n\treturn globalThis.astroAsset.imageService;\n}\n\nexport async function getImage(\n\toptions: UnresolvedImageTransform,\n\timageConfig: AstroConfig['image'] & AstroAdapterClientConfig,\n): Promise<GetImageResult> {\n\tif (!options || typeof options !== 'object') {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.ExpectedImageOptions,\n\t\t\tmessage: AstroErrorData.ExpectedImageOptions.message(JSON.stringify(options)),\n\t\t});\n\t}\n\tif (typeof options.src === 'undefined') {\n\t\tthrow new AstroError({\n\t\t\t...AstroErrorData.ExpectedImage,\n\t\t\tmessage: AstroErrorData.ExpectedImage.message(\n\t\t\t\toptions.src,\n\t\t\t\t'undefined',\n\t\t\t\tJSON.stringify(options),\n\t\t\t),\n\t\t});\n\t}\n\n\tif (isImageMetadata(options)) {\n\t\tthrow new AstroError(AstroErrorData.ExpectedNotESMImage);\n\t}\n\n\tconst service = await getConfiguredImageService();\n\n\t// If the user inlined an import, something fairly common especially in MDX, or passed a function that returns an Image, await it for them\n\tconst resolvedOptions: ImageTransform = {\n\t\t...options,","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/assets/internal.ts#L41-L77","documentation":"Thrown by getImage() when options.src is undefined. After the object-shape check passes, the next guard tests `typeof options.src === 'undefined'` and reports ExpectedImage with the (undefined) src, its type, and the full serialized options.","triggerScenarios":"Calling getImage({ ... }) where the src property is omitted or explicitly set to undefined. The destructured or spread options object never carried a src.","commonSituations":"Destructuring a frontmatter variable that doesn't exist, conditional spreads that omit src, a typo (e.g. `source` instead of `src`), or a CMS payload missing the image field.","solutions":["Ensure the options object always includes a src property.","Default or validate src before calling: if (!options.src) return;.","Check for typos — the property name is exactly `src`.","Log options before the call to confirm src is present."],"exampleFix":"// before\ngetImage({ width: 800, height: 600 })\n\n// after\ngetImage({ src: importedImage, width: 800, height: 600 })","handlingStrategy":"validation","validationCode":"function hasSrc(o: unknown): o is { src: unknown } {\n  return typeof o === 'object' && o !== null && 'src' in o && (o as any).src !== undefined;\n}","typeGuard":"function hasSrc(o: unknown): o is { src: unknown } {\n  return typeof o === 'object' && o !== null && 'src' in o && (o as any).src !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Always include src in the options object.","Validate CMS/frontmatter payloads carry an image field before rendering.","Watch for typos like `source` instead of `src`."],"tags":["images","validation","api-misuse"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}