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

Unable to convert Seq to Python

Error message

Unable to convert Seq to Python

What it means

For `Seq`-kind MiniJinja values, `from_minijinja_value` calls `from.as_seq()`; if that returns `None` (the kind says Seq but the concrete sequence object can't be obtained), it raises `Unable to convert Seq to Python`. This is an internal representation failure rather than a user-data type mismatch.

Source

Thrown at packages/cubejs-backend-native/src/template/mj_value/python.rs:46

                    format!("Converting from {:?} to Python is not supported", from),
                ))
            }
        }
        mjv::ValueKind::String => Ok(CLRepr::String(
            from.as_str()
                .expect("ValueKind::String must return string from as_str()")
                .to_string(),
            if from.is_safe() {
                StringType::Safe
            } else {
                StringType::Normal
            },
        )),
        mjv::ValueKind::Seq => {
            let seq = if let Some(seq) = from.as_seq() {
                seq
            } else {
                return Err(mj::Error::new(
                    mj::ErrorKind::InvalidOperation,
                    "Unable to convert Seq to Python".to_string(),
                ));
            };

            let mut arr = Vec::with_capacity(seq.item_count());

            for idx in 0..seq.item_count() {
                let v = if let Some(value) = seq.get_item(idx) {
                    from_minijinja_value(&value)?
                } else {
                    CLRepr::Null
                };

                arr.push(v)
            }

            Ok(CLRepr::Array(arr))

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Materialize the value in the template first (e.g. wrap in `list(...)` or iterate into a plain list).
  2. Check which value in the arguments failed — seqs nested in maps are converted recursively.
  3. Convert the value to JSON in Jinja and parse it in Python as a workaround.
  4. Report upstream if a standard MiniJinja list triggers this (indicates a native-layer bug).
Defensive patterns

Strategy: fallback

Try / catch

match from_minijinja_value(&seq_val) {
    Err(e) if e.to_string().contains("Unable to convert Seq") => {
        // serialize via JSON string instead and parse in Python
    }
    other => other?,
}

Prevention

When it happens

Trigger: A MiniJinja value whose kind is `Seq` but whose underlying object does not expose a sequence (e.g. certain custom/foreign value implementations) passed into a Python filter, method call, or nested inside another converted value.

Common situations: Passing exotic template values (custom objects pretending to be sequences) into Python interop, or proxy/iterator values that report Seq kind without a materialized sequence.

Related errors


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