{"record":{"id":"34610276c05e79e3","repo":"cube-js/cube","slug":"converting-from-to-python-is-not-supported","errorCode":null,"errorMessage":"Converting from {:?} to Python is not supported","messagePattern":"Converting from (.+?) to Python is not supported","errorType":"exception","errorClass":"minijinja::Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-native/src/template/mj_value/python.rs","lineNumber":26,"sourceCode":"use minijinja as mj;\nuse minijinja::value as mjv;\nuse minijinja::value::{Object, ObjectKind, StructObject, Value};\nuse pyo3::types::{PyDict, PyDictMethods, PyFunction};\nuse pyo3::{Py, PyObject, PyResult, Python};\nuse std::convert::TryInto;\nuse std::sync::Arc;\n\npub fn from_minijinja_value(from: &mjv::Value) -> Result<CLRepr, mj::Error> {\n    match from.kind() {\n        mjv::ValueKind::Undefined | mjv::ValueKind::None => Ok(CLRepr::Null),\n        mjv::ValueKind::Bool => Ok(CLRepr::Bool(from.is_true())),\n        mjv::ValueKind::Number => {\n            if let Ok(rv) = TryInto::<i64>::try_into(from.clone()) {\n                Ok(CLRepr::Int(rv))\n            } else if let Ok(rv) = TryInto::<f64>::try_into(from.clone()) {\n                Ok(CLRepr::Float(rv))\n            } else {\n                Err(mj::Error::new(\n                    mj::ErrorKind::InvalidOperation,\n                    format!(\"Converting from {:?} to Python is not supported\", from),\n                ))\n            }\n        }\n        mjv::ValueKind::String => Ok(CLRepr::String(\n            from.as_str()\n                .expect(\"ValueKind::String must return string from as_str()\")\n                .to_string(),\n            if from.is_safe() {\n                StringType::Safe\n            } else {\n                StringType::Normal\n            },\n        )),\n        mjv::ValueKind::Seq => {\n            let seq = if let Some(seq) = from.as_seq() {\n                seq","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-native/src/template/mj_value/python.rs#L8-L44","documentation":"`from_minijinja_value` converts MiniJinja values into Python (`CLRepr`) values. Numbers are tried as `i64` then `f64`; if the value is a `Number` kind but fits neither (or conversion fails at the TryInto level), it raises this `InvalidOperation` error. It can also be raised for unsupported kinds via the same-format catch-all at line 97.","triggerScenarios":"A Python filter/method receives a MiniJinja number that is neither integer- nor float-convertible (e.g. an out-of-range huge integer like u64 > i64::MAX), or a non-numeric kind reaching the unsupported branch (e.g. undefined, invalid, function values).","commonSituations":"Passing very large integers from a template into a Python filter (i64 overflow), passing template functions/undefined values as arguments, or Python interop over a value produced by an upstream template error.","solutions":["Check the `{:?}` debug dump in the message to see the actual value/kind.","Avoid passing integers beyond i64 range into Python filters; cast to float or string in the template.","Don't pass undefined/function template values to Python callables.","Handle the value in Jinja (e.g. `|string`) before invoking the Python filter."],"exampleFix":"// before\n{{ big_number | py_filter }}\n// after\n{{ big_number | string | py_filter }}","handlingStrategy":"type-guard","validationCode":"// in template, before passing a number to a Python filter:\n{% if v is number %}{{ v | py_filter }}{% endif %}","typeGuard":"fn is_py_safe_number(v: i128) -> bool {\n    v >= i64::MIN as i128 && v <= i64::MAX as i128\n}","tryCatchPattern":"match from_minijinja_value(&val) {\n    Err(e) if e.to_string().contains(\"not supported\") => {\n        // fall back to string/JSON conversion path\n    }\n    other => other?,\n}","preventionTips":["Avoid passing integers beyond i64 range into Python filters","Don't pass undefined or function values to Python callables","Coerce risky values to strings in Jinja before conversion"],"tags":["python","minijinja","type-conversion","template"],"backgroundTag":"unsupported-type-conversion","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}