{"record":{"id":"a898f75de69455ae","repo":"withastro/astro","slug":"expectedimageoptions","errorCode":"ExpectedImageOptions","errorMessage":"Expected `getImage()` parameter to be an object. Received `${options}`.","messagePattern":"Expected `getImage\\(\\)` parameter to be an object\\. Received `(.+?)`\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/internal.ts","lineNumber":53,"sourceCode":"\t\t\tconst error = new AstroError(AstroErrorData.InvalidImageService);\n\t\t\terror.cause = e;\n\t\t\tthrow error;\n\t\t});\n\n\t\tif (!globalThis.astroAsset) globalThis.astroAsset = {};\n\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}","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/assets/internal.ts#L35-L71","documentation":"Thrown by getImage() when the options argument is not a non-null object. The very first guard checks `!options || typeof options !== 'object'`; passing undefined, null, a primitive (string/number), or anything non-object yields ExpectedImageOptions with the JSON-serialized received value.","triggerScenarios":"Calling getImage(options, imageConfig) where options is undefined, null, a string, a number, a boolean, or an array-like that is not a plain object. Note: arrays technically pass typeof 'object', but a missing `src` would then surface a different error.","commonSituations":"Calling getImage() with no arguments, passing a raw string path instead of { src: '...' }, spreading undefined into the call, or a variable that was never assigned.","solutions":["Pass an options object: getImage({ src: ..., width: ..., height: ... }).","Wrap the call in a guard if options may be undefined: if (options) getImage(options).","Check that the variable feeding getImage is actually assigned before the call.","If using a helper, ensure it returns an object, not null/undefined."],"exampleFix":"// before\ngetImage('/img/photo.jpg')\n\n// after\ngetImage({ src: '/img/photo.jpg', width: 800, height: 600 })","handlingStrategy":"type-guard","validationCode":"function isImageOptions(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","typeGuard":"function isImageOptions(v: unknown): v is { src: unknown } {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}","tryCatchPattern":null,"preventionTips":["Always call getImage with an object literal.","Guard optional calls: if (opts) getImage(opts).","Static-type the first argument to reject primitives."],"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"}