{"record":{"id":"f769da6688e9fffb","repo":"getzola/zola","slug":"op-fit-height-requires-a-height-argument","errorCode":null,"errorMessage":"op=\"fit_height\" requires a `height` argument","messagePattern":"op=\"fit_height\" requires a `height` argument","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/imageproc/src/ops.rs","lineNumber":38,"sourceCode":"    /// The part of the image that doesn't fit in the thumbnail due to differing\n    /// aspect ratio will be cropped away, if any.\n    Fill(u32, u32),\n}\n\nimpl ResizeOperation {\n    pub fn from_args(op: &str, width: Option<u32>, height: Option<u32>) -> Result<Self> {\n        use ResizeOperation::*;\n\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        })","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/components/imageproc/src/ops.rs#L20-L56","documentation":"Symmetric to fit_width: `ResizeOperation::from_args` requires a `height` argument for `op=\"fit_height\"`, and throws this error when `height` is `None`. The operation scales the image to a given height preserving aspect ratio, which is impossible without the target height.","triggerScenarios":"Invoking a resize with `op=\"fit_height\"` but no `height` parameter, e.g. `?op=fit_height&width=200`.","commonSituations":"Misconfigured image resize URLs in templates; a generic resize helper that always passes width regardless of op; renamed config keys so height never reaches from_args.","solutions":["Add the required `height` argument alongside `op=\"fit_height\"`","If you meant to constrain by width, switch to `op=\"fit_width\"` with `width`","Ensure the caller maps dimension parameters to the correct op"],"exampleFix":"// before\nimage_resize(op=\"fit_height\", width=300)\n// after\nimage_resize(op=\"fit_height\", height=300)","handlingStrategy":"validation","validationCode":"const OP_ARG_REQS = {\n  fit_width:  [\"width\"],\n  fit_height: [\"height\"],\n  scale:      [\"width\", \"height\"],\n  fit:        [\"width\", \"height\"],\n  fill:       [\"width\", \"height\"],\n};\nfunction validateResize(op, args) {\n  const req = OP_ARG_REQS[op] || [];\n  const missing = req.filter((k) => args[k] == null);\n  if (missing.length) throw new Error(`op=\"${op}\" missing: ${missing.join(\", \")}`);\n}","typeGuard":"fn is_fit_height_args(op: &str, args: &ResizeArgs) -> bool {\n    op == \"fit_height\" && args.height.is_some()\n}","tryCatchPattern":"match ResizeOperation::from_args(op, width, height) {\n    Ok(op) => apply(op),\n    Err(e) if e.to_string().contains(\"requires a `height`\") => {\n        log::error!(\"resize URL missing height for {op}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Centralize image resize URL construction in one helper so op/argument pairing is enforced","Add a test matrix of (op, args) combinations mirroring from_args validation","When changing an op, audit the dimension arguments at the same time"],"tags":["configuration","image-resize","validation"],"backgroundTag":"missing-required-argument","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"}