{"record":{"id":"147c35a61d5f6b04","repo":"dbt-labs/dbt-core","slug":"submit-python-job-expects-2-arguments-got","errorCode":null,"errorMessage":"submit_python_job expects 2 arguments, got {}","messagePattern":"submit_python_job expects 2 arguments, got (.+?)","errorType":"exception","errorClass":"minijinja::Error (InvalidOperation)","httpStatus":null,"severity":"error","filePath":"crates/dbt-jinja-utils/src/phases/run/run_node_context.rs","lineNumber":794,"sourceCode":"        ));\n    }\n\n    match fs::write(full_path, payload) {\n        Ok(_) => Ok(()),\n        Err(e) => Err(Error::new(\n            ErrorKind::InvalidOperation,\n            format!(\"Failed to write to {}: {}\", full_path.display(), e),\n        )),\n    }\n}\n\n/// Returns the function used for the submit_python_job context.\nfn submit_python_job_context_fn()\n-> impl Fn(&State, &[MinijinjaValue]) -> Result<MinijinjaValue, Error> + Copy {\n    |state: &State, args: &[MinijinjaValue]| {\n        // Parse arguments: submit_python_job(parsed_model, compiled_code)\n        if args.len() != 2 {\n            return Err(Error::new(\n                ErrorKind::InvalidOperation,\n                format!(\"submit_python_job expects 2 arguments, got {}\", args.len()),\n            ));\n        }\n        let parsed_model = &args[0];\n        let compiled_code = args[1].as_str().ok_or_else(|| {\n            Error::new(\n                ErrorKind::InvalidOperation,\n                \"compiled_code must be a string\",\n            )\n        })?;\n\n        // Note(Ani):\n        // dbt-core validates:\n        //   - macro_stack.depth == 2\n        //   - call_stack[1] == \"macro.dbt.statement\"\n        //   - \"materialization\" in call_stack[0]\n        //","sourceCodeStart":776,"sourceCodeEnd":812,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-jinja-utils/src/phases/run/run_node_context.rs#L776-L812","documentation":"The `submit_python_job` Jinja context function registered in the run node overlay requires exactly two arguments: the parsed model object and the compiled Python code string. The library throws this arity error when the template calls `submit_python_job` with any other number of arguments. It is an eager API-contract check before any adapter work happens.","triggerScenarios":"A Jinja template calls `submit_python_job(model)` (missing compiled code), `submit_python_job()` with no args, or with three-plus args, e.g. passing an extra config object.","commonSituations":"Hand-written Python model materialization macros copied from older dbt versions with a different signature; typos like `submit_python_job(model, code, config)`; macros refactored to pass keyword-style extra params.","solutions":["Call `submit_python_job(parsed_model, compiled_code)` with exactly two positional arguments.","Remove any extra arguments (e.g. config dicts) — configuration belongs in the model config block, not this call.","Check the macro that wraps the call to make sure it forwards exactly two values."],"exampleFix":"-- before\n{% do submit_python_job(model, compiled_code, config) %}\n-- after\n{% do submit_python_job(model, compiled_code) %}\n","handlingStrategy":"validation","validationCode":"-- Jinja pre-check before the call\n{% if var_args | length != 2 %}\n  {{ exceptions.raise_compiler_error('submit_python_job needs exactly (model, compiled_code)') }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call submit_python_job(model, compiled_code) with exactly two positional args.","Keep config in the model config block, not as a third argument.","Wrap the call in a single helper macro so the signature is defined once."],"tags":["jinja","arity","python-models"],"backgroundTag":"missing-required-argument","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}