gatsbyjs/gatsby · error

No valid layout was provided for the image at ${file.absolut

Error message

No valid layout was provided for the image at ${file.absolutePath}. Valid image layouts are fixed, fullWidth, and constrained.

What it means

Layout validation error path in gatsby-plugin-sharp's calculateImageSizes: after verifying user-supplied width/height are positive, the `layout` matched neither `fixed` nor `fullWidth`/`constrained`, so no sizing branch applies and this error identifying the invalid layout value (and file.absolutePath) is produced.

Source

Thrown at packages/gatsby-plugin-sharp/src/utils.js:37

  // check that all dimensions provided are positive
  const userDimensions = { width, height }
  const erroneousUserDimensions = Object.entries(userDimensions).filter(
    ([_, size]) => typeof size === `number` && size < 1
  )
  if (erroneousUserDimensions.length) {
    throw new Error(
      `Specified dimensions for images must be positive numbers (> 0). Problem dimensions you have are ${erroneousUserDimensions
        .map(dim => dim.join(`: `))
        .join(`, `)}`
    )
  }

  if (layout === `fixed`) {
    return fixedImageSizes(args)
  } else if (layout === `fullWidth` || layout === `constrained`) {
    return responsiveImageSizes(args)
  } else {
    reporter.warn(
      `No valid layout was provided for the image at ${file.absolutePath}. Valid image layouts are fixed, fullWidth, and constrained.`
    )
    return []
  }
}

export function fixedImageSizes({
  file,
  imgDimensions,
  width,
  height,
  transformOptions = {},
  outputPixelDensities = DEFAULT_PIXEL_DENSITIES,
  reporter,
}) {
  let aspectRatio = imgDimensions.width / imgDimensions.height
  const { fit = `cover` } = transformOptions
  // Sort, dedupe and ensure there's a 1

View on GitHub (pinned to e85d62f177)

Solutions

  1. Pass a valid layout (fixed, fullWidth or constrained) to the image resolver
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/gatsby-plugin-sharp/src/utils.js:37 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gatsbyjs/gatsby@e85d62f177 (2026-08-26). Data as JSON: /api/errors/005446e6e7b62010. Report an issue: GitHub.