{"record":{"id":"dcd62932c721d5f6","repo":"getzola/zola","slug":"invalid-image-format","errorCode":null,"errorMessage":"Invalid image format: {}","messagePattern":"Invalid image format: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/imageproc/src/format.rs","lineNumber":82,"sourceCode":"                    invalid_quality => Err(anyhow!(\n                        \"Quality for AVIF must be between {} and {} (inclusive); {} is not valid\",\n                        QUALITY_MIN_AVIF,\n                        QUALITY_MAX_AVIF,\n                        invalid_quality\n                    )),\n                }?;\n                let s = match speed.unwrap_or(DEFAULT_SPEED_AVIF) {\n                    valid_speed @ SPEED_MIN_AVIF..=SPEED_MAX_AVIF => Ok(valid_speed),\n                    invalid_speed => Err(anyhow!(\n                        \"Speed for AVIF must be between {} and {} (inclusive); {} is not valid\",\n                        SPEED_MIN_AVIF,\n                        SPEED_MAX_AVIF,\n                        invalid_speed\n                    )),\n                }?;\n                Ok(Avif { quality: q, speed: s })\n            }\n            _ => Err(anyhow!(\"Invalid image format: {}\", format)),\n        }\n    }\n\n    pub fn extension(&self) -> &str {\n        // Kept in sync with RESIZED_FILENAME and op_filename\n        use Format::*;\n\n        match *self {\n            Png => \"png\",\n            Jpeg { .. } => \"jpg\",\n            WebP { .. } => \"webp\",\n            Avif { .. } => \"avif\",\n        }\n    }\n}\n\n#[allow(clippy::derived_hash_with_manual_eq)]\nimpl Hash for Format {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/imageproc/src/format.rs#L64-L100","documentation":"`Format::from_args` parses a user-supplied format string (e.g. from imageproc config) into the `Format` enum. The match only accepts recognized formats such as `avif`; any other string falls into the catch-all `_` arm and produces this anyhow error. It is a configuration/parsing validation error, not a runtime image decoding failure.","triggerScenarios":"Calling `Format::from_args` with a format string that is not one of the supported enum variants (e.g. a typo like \"jpg\" vs \"jpeg\", or \"webp\" misspelled), typically via the `[imageproc]` settings or an image resize URL/config.","commonSituations":"Typos in zola config.toml image processing settings; copy-pasting format names from other tools (e.g. 'jpg' when the code expects 'jpeg'); passing an uppercase or whitespace-padded format string that is not normalized before matching.","solutions":["Check the format string against the exact variants accepted by the `match` in `Format::from_args` (jpeg, png, webp, avif, bmp, etc.) and fix the spelling/case","Trim whitespace and lowercase the input before passing it in","Update the zola/imageproc version docs to confirm which formats the installed version supports"],"exampleFix":"// before (config)\nformat = \"jpg\"\n// after\nformat = \"jpeg\"","handlingStrategy":"validation","validationCode":"const FORMATS: [&str; 6] = [\"jpeg\", \"png\", \"webp\", \"avif\", \"bmp\", \"tiff\"];\nfn is_valid_format(f: &str) -> bool {\n    FORMATS.contains(&f.trim().to_ascii_lowercase().as_str())\n}\nif !is_valid_format(cfg.format) { eprintln!(\"unsupported format: {}\", cfg.format); }","typeGuard":"fn is_supported_format(f: &str) -> bool {\n    matches!(f.trim().to_ascii_lowercase().as_str(), \"jpeg\" | \"png\" | \"webp\" | \"avif\" | \"bmp\" | \"tiff\")\n}","tryCatchPattern":"match Format::from_args(&raw) {\n    Ok(f) => process(f),\n    Err(e) if e.to_string().starts_with(\"Invalid image format\") => {\n        log::error!(\"config format rejected: {e}; use one of jpeg/png/webp/avif/bmp/tiff\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep a canonical allowlist of format strings and lowercase/trim user input before parsing","Add a unit test for Format::from_args covering every accepted variant and common typos","Reference format names from the enum/doc rather than hand-typing them in config"],"tags":["configuration","image-processing","validation"],"backgroundTag":"invalid-format-string","analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}