{"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":210,"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":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/assets/services/service.ts#L192-L228","documentation":"`verifyOptions()` rejects transforms that specify both `widths` and `densities` (packages/astro/src/assets/services/service.ts:199) with `IncompatibleDescriptorOptions`. Both parameters describe the same thing — the srcset descriptors for responsive output — so giving both is ambiguous and the API refuses to guess.","triggerScenarios":"`<Picture src={hero} widths={[400, 800]} densities={[1, 2]} ...>` or `getImage({ src, widths: [...], densities: [...] })` — both keys present on the same transform.","commonSituations":"Copy-pasting responsive snippets that mix the two APIs; upgrading older examples that used `densities` into code that already sets `widths`; editor auto-complete adding the wrong prop.","solutions":["Keep only one descriptor option — usually `widths` when you need specific pixel widths (`widths={[400, 800, 1600]}`).","If you think in device-pixel-ratios instead, keep `densities={[1, 2]}` and remove `widths`.","Search the codebase for components spreading both props into `<Picture>`/`getImage` and split them."],"exampleFix":"// before\n<Picture src={hero} widths={[400, 800]} densities={[1, 2]} alt=\"Hero\" formats={['avif', 'webp']} />\n\n// after\n<Picture src={hero} widths={[400, 800]} alt=\"Hero\" formats={['avif', 'webp']} />","handlingStrategy":"validation","validationCode":"if (widths && densities) {\n  throw new Error('Pass only one of widths or densities, not both');\n}","typeGuard":"type DescriptorOptions =\n  | { widths: number[]; densities?: undefined }\n  | { widths?: undefined; densities: number[] };\n\n// exhaustive assignment makes passing both a compile error\nconst descriptors: DescriptorOptions = { widths: [400, 800] };","tryCatchPattern":null,"preventionTips":["Standardize the team on widths (or densities) and lint for the other prop.","Review responsive snippets before copy-pasting them into Picture components."],"tags":["images","picture-component","responsive-images","api-usage"],"backgroundTag":"conflicting-options","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}