{"record":{"id":"5c1df776d1ded4d0","repo":"withastro/astro","slug":"invalid-quality-for-picture-options-src","errorCode":null,"errorMessage":"Invalid quality for picture \"${options.src}\"","messagePattern":"Invalid quality for picture \"(.+?)\"","errorType":"validation","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/integrations/netlify/src/image-service.ts","lineNumber":67,"sourceCode":"\t\treturn `/.netlify/images?${query}`;\n\t},\n\tgetHTMLAttributes: baseService.getHTMLAttributes,\n\tgetSrcSet: baseService.getSrcSet,\n\tvalidateOptions(options) {\n\t\tverifyOptions(options);\n\n\t\tif (options.format && !SUPPORTED_FORMATS.includes(options.format)) {\n\t\t\tthrow new AstroError(\n\t\t\t\t`Unsupported image format \"${options.format}\"`,\n\t\t\t\t`Use one of ${SUPPORTED_FORMATS.join(', ')} instead.`,\n\t\t\t);\n\t\t}\n\n\t\tif (options.quality) {\n\t\t\toptions.quality =\n\t\t\t\ttypeof options.quality === 'string' ? QUALITY_NAMES[options.quality] : options.quality;\n\t\t\tif (options.quality < 1 || options.quality > 100) {\n\t\t\t\tthrow new AstroError(\n\t\t\t\t\t`Invalid quality for picture \"${options.src}\"`,\n\t\t\t\t\t'Quality needs to be between 1 and 100.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn options;\n\t},\n};\n\nexport default service;\n","sourceCodeStart":49,"sourceCodeEnd":78,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/integrations/netlify/src/image-service.ts#L49-L78","documentation":"After mapping named qualities (`low`/`mid`/`high`/`max` → 25/50/90/100), the Netlify service checks numeric quality is within `[1,100]`. Anything outside — including `0`, negative numbers, or values above 100 — throws `AstroError` naming the picture source. This mirrors Netlify Image CDN's valid quality range.","triggerScenarios":"Passing `quality: 0`, `quality: 150`, a negative number, or a numeric string outside 1–100 to `getImage`/`getPicture` under the Netlify service. A named quality that resolves (via `QUALITY_NAMES`) to an out-of-range number (not possible with defaults, but a custom override could).","commonSituations":"Copy-pasting a sharp config that allows `quality: 0`. Treating quality as a 0–1 float. Migrating from another service with a different range.","solutions":["Set `quality` to an integer between 1 and 100 inclusive.","Use a named quality: `low`, `mid`, `high`, or `max`.","If passing a 0–1 float, multiply by 100 first.","Omit `quality` to use the service default."],"exampleFix":"// before\nawait getImage({ src, quality: 0.8 });\n\n// after\nawait getImage({ src, quality: 80 });","handlingStrategy":"validation","validationCode":"function clampNetlifyQuality(q: number | string | undefined): number | undefined {\n  if (q == null) return undefined;\n  const n = typeof q === 'string' ? ({ low: 25, mid: 50, high: 90, max: 100 } as Record<string, number>)[q] ?? Number(q) : q;\n  if (!Number.isFinite(n) || n < 1 || n > 100) {\n    throw new Error('Netlify image quality must be an integer between 1 and 100');\n  }\n  return n;\n}","typeGuard":"function isNetlifyQuality(q: unknown): boolean {\n  const n = typeof q === 'number' ? q : NaN;\n  return Number.isInteger(n) && n >= 1 && n <= 100;\n}","tryCatchPattern":null,"preventionTips":["Pass integer quality between 1 and 100 (or a named value).","Convert 0–1 floats to percent before passing.","Validate at config boundaries when migrating services."],"tags":["netlify","images","validation","configuration"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}