{"record":{"id":"f0331c206f303b2d","repo":"withastro/astro","slug":"astro-expected-an-svg-for-transform-src-but-t","errorCode":null,"errorMessage":"Astro expected an SVG for \"${transform.src}\" but the source is ${bufferFormat}. Passing it through as ${bufferFormat} instead.","messagePattern":"Astro expected an SVG for \"(.+?)\" but the source is (.+?)\\. Passing it through as (.+?) instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/astro/src/assets/services/sharp.ts","lineNumber":161,"sourceCode":"\tvalidateOptions: baseService.validateOptions,\n\tgetURL: baseService.getURL,\n\tparseURL: baseService.parseURL,\n\tgetHTMLAttributes: baseService.getHTMLAttributes,\n\tgetSrcSet: baseService.getSrcSet,\n\tgetRemoteSize: baseService.getRemoteSize,\n\tasync transform(inputBuffer, transformOptions, config, logger) {\n\t\tif (!sharp) sharp = await loadSharp();\n\t\tconst transform: BaseServiceTransform = transformOptions as BaseServiceTransform;\n\t\tconst kernel = config.service.config.kernel;\n\n\t\tconst bufferFormat = detector(inputBuffer);\n\t\t// Resolve the output format from the buffer when validateOptions deferred (ambiguous remote URL hit SSR, manually formed URLs etc)\n\t\tconst outputFormat = transform.format ?? resolveDefaultOutputFormat(bufferFormat);\n\n\t\t// TODO: Sharp has some support for SVGs, we could probably support this once Sharp is the default and only service.\n\t\tif (outputFormat === 'svg') {\n\t\t\tif (bufferFormat && bufferFormat !== 'svg') {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t`Astro expected an SVG for \"${transform.src}\" but the source is ${bufferFormat}. Passing it through as ${bufferFormat} instead.`,\n\t\t\t\t);\n\t\t\t\treturn { data: inputBuffer, format: bufferFormat as ImageOutputFormat };\n\t\t\t}\n\t\t\treturn { data: inputBuffer, format: 'svg' };\n\t\t}\n\n\t\t// If we couldn't figure out the format, it's probably something weird we shouldn't try to process.\n\t\tif (!bufferFormat) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.NoImageMetadata,\n\t\t\t\tmessage: AstroErrorData.NoImageMetadata.message(transform.src),\n\t\t\t});\n\t\t}\n\n\t\tif (bufferFormat === 'svg' && !config.dangerouslyProcessSVG) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnsupportedImageFormat,","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/assets/services/sharp.ts#L143-L179","documentation":"In the Sharp image service, transform() was asked to process an image whose declared/configured format is SVG, but format detection on the actual input buffer identified it as a different format (bufferFormat). Instead of failing, Sharp passes the buffer through unoptimized in its detected format and logs this warning, so the build does not break on a mismatched extension or mislabeled src.","triggerScenarios":"Thrown at packages/astro/src/assets/services/sharp.ts:161 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the source file truly is an SVG — its extension or config entry may mislabel a JPEG/PNG as .svg","If the file is intentionally another format, update its extension or the image's format option to match","Rename or fix the file so the declared format matches the actual encoded format"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-09-09T03:35:40.650Z","contentChangedAt":"2026-09-09T03:35:40.650Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}