{"record":{"id":"1daa513188b0c8ac","repo":"gatsbyjs/gatsby","slug":"all-ints-in-srcsetbreakpoints-should-be-positive-i","errorCode":null,"errorMessage":"All ints in srcSetBreakpoints should be positive ints larger than zero (> 0), found ${breakpoint}","messagePattern":"All ints in srcSetBreakpoints should be positive ints larger than zero \\(> 0\\), found (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/gatsby-plugin-sharp/src/index.js","lineNumber":477,"sourceCode":"  // is 800px, the sizes would then be: 200, 400, 800, 1200, 1600.\n  //\n  // This is enough sizes to provide close to the optimal image size for every\n  // device size / screen resolution while (hopefully) not requiring too much\n  // image processing time (Sharp has optimizations thankfully for creating\n  // multiple sizes of the same input file)\n  const fluidSizes = [\n    options[fixedDimension], // ensure maxWidth (or maxHeight) is added\n  ]\n  // use standard breakpoints if no custom breakpoints are specified\n  if (!options.srcSetBreakpoints || !options.srcSetBreakpoints.length) {\n    fluidSizes.push(options[fixedDimension] / 4)\n    fluidSizes.push(options[fixedDimension] / 2)\n    fluidSizes.push(options[fixedDimension] * 1.5)\n    fluidSizes.push(options[fixedDimension] * 2)\n  } else {\n    options.srcSetBreakpoints.forEach(breakpoint => {\n      if (breakpoint < 1) {\n        throw new Error(\n          `All ints in srcSetBreakpoints should be positive ints larger than zero (> 0), found ${breakpoint}`\n        )\n      }\n      // ensure no duplicates are added\n      if (fluidSizes.includes(breakpoint)) {\n        return\n      }\n      fluidSizes.push(breakpoint)\n    })\n  }\n  let filteredSizes = fluidSizes.filter(\n    size => size < (fixedDimension === `maxWidth` ? width : height)\n  )\n\n  // Add the original image to ensure the largest image possible\n  // is available for small images. Also so we can link to\n  // the original image.\n  filteredSizes.push(fixedDimension === `maxWidth` ? width : height)","sourceCodeStart":459,"sourceCodeEnd":495,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby-plugin-sharp/src/index.js#L459-L495","documentation":"gatsby-plugin-sharp accepts a custom `srcSetBreakpoints` array to control responsive image breakpoints beyond the defaults. Each breakpoint must be a positive integer > 0; if any element is < 1 (0, negative, or NaN from arithmetic), the loop throws. Breakpoints also must not duplicate the base size, but duplicates are silently skipped - only the < 1 case throws.","triggerScenarios":"Passing srcSetBreakpoints={[0, 400, 800]}, srcSetBreakpoints={[-1]}, or a breakpoint derived from a divide that yields 0/NaN, e.g. to a Gatsby Image component or the sharp fluid API.","commonSituations":"Generating breakpoints from a container width that is 0 at first paint; copy-pasting a config with a 0 placeholder; mixing units (passing '400px' strings that coerce to NaN).","solutions":["Provide only positive integers: srcSetBreakpoints={[400, 800, 1200]}.","Filter/clamp generated breakpoints: bp.filter(n => Number.isInteger(n) && n > 0).","Omit srcSetBreakpoints entirely to use the default [size/4, size/2, size*1.5, size*2]."],"exampleFix":"// before\n<StaticImage src=\"./hero.jpg\" srcSetBreakpoints={[0, 750]} />\n\n// after\n<StaticImage src=\"./hero.jpg\" srcSetBreakpoints={[750]} />","handlingStrategy":"validation","validationCode":"function sanitizeBreakpoints(bp) {\n  if (!Array.isArray(bp)) return undefined;\n  const clean = bp.filter(n => Number.isInteger(n) && n > 0);\n  return clean.length ? clean : undefined;\n}","typeGuard":"function areValidBreakpoints(bp) {\n  return Array.isArray(bp) && bp.every(n => Number.isInteger(n) && n > 0);\n}","tryCatchPattern":null,"preventionTips":["Type srcSetBreakpoints as number[] in component props and validate.","Filter generated breakpoints before passing them to sharp.","Prefer omitting the option to use the safe defaults."],"tags":["gatsby-plugin-sharp","image-processing","validation","responsive-images"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}