getzola/zola · error

op="fit_height" requires a `height` argument

Error message

op="fit_height" requires a `height` argument

What it means

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.

Source

Thrown at components/imageproc/src/ops.rs:38

    /// The part of the image that doesn't fit in the thumbnail due to differing
    /// aspect ratio will be cropped away, if any.
    Fill(u32, u32),
}

impl ResizeOperation {
    pub fn from_args(op: &str, width: Option<u32>, height: Option<u32>) -> Result<Self> {
        use ResizeOperation::*;

        // Validate args:
        match op {
            "fit_width" => {
                if width.is_none() {
                    return Err(anyhow!("op=\"fit_width\" requires a `width` argument"));
                }
            }
            "fit_height" => {
                if height.is_none() {
                    return Err(anyhow!("op=\"fit_height\" requires a `height` argument"));
                }
            }
            "scale" | "fit" | "fill" => {
                if width.is_none() || height.is_none() {
                    return Err(anyhow!("op={} requires a `width` and `height` argument", op));
                }
            }
            _ => return Err(anyhow!("Invalid image resize operation: {}", op)),
        };

        Ok(match op {
            "scale" => Scale(width.unwrap(), height.unwrap()),
            "fit_width" => FitWidth(width.unwrap()),
            "fit_height" => FitHeight(height.unwrap()),
            "fit" => Fit(width.unwrap(), height.unwrap()),
            "fill" => Fill(width.unwrap(), height.unwrap()),
            _ => unreachable!(),
        })

View on GitHub (pinned to 61d3082821)

Solutions

  1. Add the required `height` argument alongside `op="fit_height"`
  2. If you meant to constrain by width, switch to `op="fit_width"` with `width`
  3. Ensure the caller maps dimension parameters to the correct op

Example fix

// before
image_resize(op="fit_height", width=300)
// after
image_resize(op="fit_height", height=300)
Defensive patterns

Strategy: validation

Validate before calling

const OP_ARG_REQS = {
  fit_width:  ["width"],
  fit_height: ["height"],
  scale:      ["width", "height"],
  fit:        ["width", "height"],
  fill:       ["width", "height"],
};
function validateResize(op, args) {
  const req = OP_ARG_REQS[op] || [];
  const missing = req.filter((k) => args[k] == null);
  if (missing.length) throw new Error(`op="${op}" missing: ${missing.join(", ")}`);
}

Type guard

fn is_fit_height_args(op: &str, args: &ResizeArgs) -> bool {
    op == "fit_height" && args.height.is_some()
}

Try / catch

match ResizeOperation::from_args(op, width, height) {
    Ok(op) => apply(op),
    Err(e) if e.to_string().contains("requires a `height`") => {
        log::error!("resize URL missing height for {op}");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Invoking a resize with `op="fit_height"` but no `height` parameter, e.g. `?op=fit_height&width=200`.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03). Data as JSON: /api/errors/f769da6688e9fffb. Report an issue: GitHub.