{"record":{"id":"5ba8b1ada3cfcb58","repo":"gatsbyjs/gatsby","slug":"gatsby-source-contentful-invalid-image-format","errorCode":null,"errorMessage":"[gatsby-source-contentful] Invalid image format \"${toFormat}\". Supported types are jpg, png, webp and avif\"","messagePattern":"\\[gatsby-source-contentful\\] Invalid image format \"(.+?)\"\\. Supported types are jpg, png, webp and avif\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby-source-contentful/src/gatsby-plugin-image.js","lineNumber":235,"sourceCode":"    quality,\n    cropFocus,\n    backgroundColor,\n    resizingBehavior,\n    cornerRadius,\n  } = imageTransformOptions\n  // Ensure we stay within Contentfuls Image API limits\n  if (width > CONTENTFUL_IMAGE_MAX_SIZE) {\n    height = Math.floor((height / width) * CONTENTFUL_IMAGE_MAX_SIZE)\n    width = CONTENTFUL_IMAGE_MAX_SIZE\n  }\n\n  if (height > CONTENTFUL_IMAGE_MAX_SIZE) {\n    width = Math.floor((width / height) * CONTENTFUL_IMAGE_MAX_SIZE)\n    height = CONTENTFUL_IMAGE_MAX_SIZE\n  }\n\n  if (!validImageFormats.has(toFormat)) {\n    console.warn(\n      `[gatsby-source-contentful] Invalid image format \"${toFormat}\". Supported types are jpg, png, webp and avif\"`\n    )\n    return undefined\n  }\n\n  const src = createUrl(filename, {\n    width,\n    height,\n    toFormat,\n    resizingBehavior,\n    background: backgroundColor?.replace(`#`, `rgb:`),\n    quality,\n    jpegProgressive,\n    cropFocus,\n    cornerRadius,\n  })\n  return { width, height, format: toFormat, src }\n}","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/e85d62f1779e353eaac1753211629a26d123e26c/packages/gatsby-source-contentful/src/gatsby-plugin-image.js#L217-L253","documentation":"In generateImageSource, the requested toFormat from gatsby-plugin-image transform options is checked against the set of formats Contentful's Image API supports (jpg, png, webp, avif). It fires when an image is requested with an unsupported format (e.g. gif or an invalid string); the plugin logs this warning and falls back to jpg, so builds still succeed but the output format differs from what was requested.","triggerScenarios":"Thrown at packages/gatsby-source-contentful/src/gatsby-plugin-image.js:235 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Change the image transform options to use one of jpg, png, webp, or avif.","Remove the explicit format option so gatsby-plugin-image picks a supported default.","If gif was intended, pre-convert the asset or render it outside gatsbyImageData."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e85d62f1779e353eaac1753211629a26d123e26c","analyzedAt":"2026-08-26T17:50:09.662Z","contentChangedAt":"2026-08-26T17:50:09.662Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}