{"record":{"id":"d7193adbcf2eb0ce","repo":"getzola/zola","slug":"invalid-image-resize-operation","errorCode":null,"errorMessage":"Invalid image resize operation: {}","messagePattern":"Invalid image resize operation: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/imageproc/src/ops.rs","lineNumber":46,"sourceCode":"\n        // Validate args:\n        match op {\n            \"fit_width\" => {\n                if width.is_none() {\n                    return Err(anyhow!(\"op=\\\"fit_width\\\" requires a `width` argument\"));\n                }\n            }\n            \"fit_height\" => {\n                if height.is_none() {\n                    return Err(anyhow!(\"op=\\\"fit_height\\\" requires a `height` argument\"));\n                }\n            }\n            \"scale\" | \"fit\" | \"fill\" => {\n                if width.is_none() || height.is_none() {\n                    return Err(anyhow!(\"op={} requires a `width` and `height` argument\", op));\n                }\n            }\n            _ => return Err(anyhow!(\"Invalid image resize operation: {}\", op)),\n        };\n\n        Ok(match op {\n            \"scale\" => Scale(width.unwrap(), height.unwrap()),\n            \"fit_width\" => FitWidth(width.unwrap()),\n            \"fit_height\" => FitHeight(height.unwrap()),\n            \"fit\" => Fit(width.unwrap(), height.unwrap()),\n            \"fill\" => Fill(width.unwrap(), height.unwrap()),\n            _ => unreachable!(),\n        })\n    }\n}\n\n/// Contains image crop/resize instructions for use by `Processor`\n///\n/// The `Processor` applies `crop` first, if any, and then `resize`, if any.\n#[derive(Clone, PartialEq, Eq, Hash, Default, Debug)]\npub struct ResizeInstructions {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/imageproc/src/ops.rs#L28-L64","documentation":"After validating required arguments, `ResizeOperation::from_args` maps the op string to an enum variant. Any op string not in {fit_width, fit_height, scale, fit, fill} hits the `_` arm and fails with this error listing the invalid op.","triggerScenarios":"Passing an unknown or misspelled resize operation name, e.g. `op=\"resize\"`, `op=\"crop\"`, `op=\"Fit\"` (case mismatch), or `op=\"fit-width\"` (wrong separator).","commonSituations":"Typos in template image resize calls; copying op names from other image libraries (sharp, ImageMagick) that use different vocabulary; version differences where an op was renamed or removed.","solutions":["Correct the op string to one of the supported values: scale, fit, fit_width, fit_height, fill","Check the documentation for your installed version for the exact op names","Validate user-supplied op values against an allowlist before calling"],"exampleFix":"// before\nimage_resize(op=\"resize\", width=300, height=200)\n// after\nimage_resize(op=\"scale\", width=300, height=200)","handlingStrategy":"validation","validationCode":"const OPS = new Set([\"scale\", \"fit\", \"fit_width\", \"fit_height\", \"fill\"]);\nfunction isValidOp(op) {\n  return OPS.has(op);\n}\nif (!isValidOp(op)) throw new Error(`unknown resize op: ${op}; use ${[...OPS].join(\"|\")}`);","typeGuard":"fn is_valid_resize_op(op: &str) -> bool {\n    matches!(op, \"scale\" | \"fit\" | \"fit_width\" | \"fit_height\" | \"fill\")\n}","tryCatchPattern":"match ResizeOperation::from_args(op, width, height) {\n    Ok(op) => apply(op),\n    Err(e) if e.to_string().starts_with(\"Invalid image resize operation\") => {\n        log::error!(\"unknown op '{}'; use scale|fit|fit_width|fit_height|fill\", op);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep an allowlist of op strings and validate before calling; reject early with the accepted values in the message","Add a unit test enumerating all valid ops against from_args","Never copy op vocabulary from other image libraries without checking this crate's docs"],"tags":["configuration","image-resize","validation"],"backgroundTag":"invalid-enum-value","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"}