cube-js/cube · error · minijinja::Error

Error while calling filter: {}

Error message

Error while calling filter: {}

What it means

The Python extension for MiniJinja wraps Python callables as Jinja filters. When a template invokes such a filter and the underlying Python function raises, `python_fn_call_sync` returns an error and the wrapper converts it into a MiniJinja `InvalidOperation` error with this message. The original Python traceback text is embedded in `{err}`.

Source

Thrown at packages/cubejs-backend-native/src/template/engine_python.rs:54

                    other.kind()
                ))
            }
        };

        engine.add_filter(
            filter_name.value(cx),
            move |_state: &mj::State,
                  args: &[mj::value::Value]|
                  -> Result<mj::value::Value, mj::Error> {
                let mut arguments = Vec::with_capacity(args.len());

                for arg in args {
                    arguments.push(from_minijinja_value(arg)?);
                }

                match python_fn_call_sync(&py_fun, arguments) {
                    Ok(r) => Ok(to_minijinja_value(r)),
                    Err(err) => Err(mj::Error::new(
                        minijinja::ErrorKind::InvalidOperation,
                        format!("Error while calling filter: {}", err),
                    )),
                }
            },
        );
    }

    Ok(())
}

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Read the `{err}` suffix — it contains the Python exception and usually the failing line.
  2. Fix or add input validation inside the Python filter function.
  3. Ensure all argument types passed from the template are convertible (numbers, strings, seqs, string-keyed maps).
  4. Test the filter function directly in Python with representative template inputs.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    result = my_filter(value)
except Exception as e:
    # the MiniJinja error embeds this Python exception text
    raise RuntimeError(f"filter input invalid: {value!r}") from e

Prevention

When it happens

Trigger: A template calls a registered Python filter/function and that function throws (any Python exception) or its arguments cannot be converted from MiniJinja values (see `from_minijinja_value` failures).

Common situations: User-defined Python filter raising on unexpected input (None where a number is expected), type errors from mismatched arguments, missing Python dependencies inside the native runtime.

Related errors


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/b9e2997e564459aa. Report an issue: GitHub.