{"record":{"id":"3f0b69fb94d2527e","repo":"cube-js/cube","slug":"unable-to-call-method-on-py-function","errorCode":null,"errorMessage":"Unable to call method on Py<Function>","messagePattern":"Unable to call method on Py<Function>","errorType":"exception","errorClass":"minijinja::Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-native/src/template/mj_value/python.rs","lineNumber":237,"sourceCode":"\nimpl std::fmt::Display for JinjaPythonFunction {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        std::fmt::Display::fmt(&self.inner, f)\n    }\n}\n\nimpl Object for JinjaPythonFunction {\n    fn kind(&self) -> ObjectKind<'_> {\n        ObjectKind::Plain\n    }\n\n    fn call_method(\n        &self,\n        _state: &mj::State,\n        _name: &str,\n        _args: &[Value],\n    ) -> Result<Value, mj::Error> {\n        Err(mj::Error::new(\n            minijinja::ErrorKind::InvalidOperation,\n            \"Unable to call method on Py<Function>\",\n        ))\n    }\n\n    fn call(&self, _state: &mj::State, args: &[Value]) -> Result<Value, mj::Error> {\n        let mut arguments = Vec::with_capacity(args.len());\n\n        for arg in args {\n            arguments.push(from_minijinja_value(arg)?);\n        }\n\n        let py_runtime = py_runtime().map_err(|err| {\n            mj::Error::new(\n                mj::ErrorKind::EvalBlock,\n                format!(\"Python runtime error: {}\", err),\n            )\n        })?;","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-native/src/template/mj_value/python.rs#L219-L255","documentation":"A sentinel guard for JinjaPythonFunction: calling a method on a Python function object (e.g. {{ myfunc.upper }}) is unsupported. Python functions exposed to templates can only be invoked directly via call — attribute/method dispatch on them is deliberately rejected rather than delegated to Python.","triggerScenarios":"Thrown at packages/cubejs-backend-native/src/template/mj_value/python.rs:237 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invoke the exposed Python function directly, e.g. {{ myfunc(arg) }}, instead of calling methods on it","Expose a Python object with methods if per-method dispatch is needed"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}