{"record":{"id":"c07ad29897628c59","repo":"withastro/astro","slug":"incompatibledescriptoroptions","errorCode":"IncompatibleDescriptorOptions","errorMessage":"Only one of `densities` or `widths` can be specified. In most cases, you'll probably want to use only `widths` if you require specific widths.","messagePattern":"Only one of `densities` or `widths` can be specified\\. In most cases, you'll probably want to use only `widths` if you require specific widths\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/services/service.ts","lineNumber":199,"sourceCode":"\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.MissingImageDimension,\n\t\t\t\tmessage: AstroErrorData.MissingImageDimension.message(missingDimension, options.src),\n\t\t\t});\n\t\t}\n\t} else {\n\t\tif (!VALID_SUPPORTED_FORMATS.includes(options.src.format as any)) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnsupportedImageFormat,\n\t\t\t\tmessage: AstroErrorData.UnsupportedImageFormat.message(\n\t\t\t\t\toptions.src.format,\n\t\t\t\t\toptions.src.src,\n\t\t\t\t\tVALID_SUPPORTED_FORMATS,\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\n\t\tif (options.widths && options.densities) {\n\t\t\tthrow new AstroError(AstroErrorData.IncompatibleDescriptorOptions);\n\t\t}\n\n\t\tif (options.src.format !== 'svg' && options.format === 'svg') {\n\t\t\tthrow new AstroError(AstroErrorData.UnsupportedImageConversion);\n\t\t}\n\t}\n}\n\n/**\n * Basic local service using the included `_image` endpoint.\n * This service intentionally does not implement `transform`.\n *\n * Example usage:\n * ```ts\n * const service = {\n *  getURL: baseService.getURL,\n *  parseURL: baseService.parseURL,\n *  getHTMLAttributes: baseService.getHTMLAttributes,","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/assets/services/service.ts#L181-L217","documentation":"Thrown by verifyOptions() when both options.widths and options.densities are set on an ESM-imported image. These are mutually exclusive responsive-image descriptors; specifying both is ambiguous, so Astro rejects it with IncompatibleDescriptorOptions and recommends widths when specific widths are needed.","triggerScenarios":"Passing <Image src={imported} widths={[...]} densities={[...]} /> or getImage({ src, widths, densities }) simultaneously. The guard `if (options.widths && options.densities)` fires for ESM-imported sources.","commonSituations":"Author copies a snippet that had both, or iteratively added densities then widths without removing the other. Common when tuning responsive images.","solutions":["Use only widths OR only densities, not both.","Prefer widths when you need specific pixel widths.","Prefer densities (e.g. [1,2,3]) when targeting device pixel ratios.","Remove the unused property from the component/getImage call."],"exampleFix":"// before\n<Image src={photo} widths={[240, 540, 720]} densities={[1, 2]} />\n\n// after\n<Image src={photo} widths={[240, 540, 720]} />","handlingStrategy":"validation","validationCode":"function hasOneDescriptor(o: { widths?: unknown; densities?: unknown }): boolean {\n  return !(o.widths && o.densities);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one responsive strategy (widths XOR densities) per image.","Remove unused descriptor properties when switching strategies.","Document the chosen convention in shared image components."],"tags":["images","responsive","validation"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}