dbt-labs/dbt-core · error
database is required
Error message
database is required
What it means
Invariant expect in finalize_python_code: the model value is expected to always carry a `database` attribute (Snowflake models always have a database), but the attribute was missing or not a string, so the Python job's target path cannot be built. Indicates the model object passed in is not a properly populated Snowflake model node.
Solutions
- Ensure the model node has a database set (check profile/target configuration)
- Verify the model value passed to submit_python_job is a real model node, not a test stub missing `database`
- Report as an internal bug if the database is genuinely absent in a valid run
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/dbt-adapter/src/python/snowflake/mod.rs:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/cc0b7290ed7d931c.
Report an issue: GitHub.
Appendix: source
Thrown at crates/dbt-adapter/src/python/snowflake/mod.rs:20
use minijinja::{State, Value};
const DEFAULT_SNOWFLAKE_PYTHON_PACKAGE: &str = "snowflake-snowpark-python";
pub fn finalize_python_code(
state: &State,
model: &Value,
compiled_code: &str,
) -> AdapterResult<String> {
// Extract config from model
let config = model
.get_attr("config")
.map_err(|e| AdapterError::new(AdapterErrorKind::Internal, e.to_string()))?;
let database = model
.get_attr("database")
.ok()
.and_then(|v| v.as_str().map(|s| s.to_string()))
.expect("database is required");
let schema = model
.get_attr("schema")
.ok()
.and_then(|v| v.as_str().map(|s| s.to_string()))
.expect("schema is required");
let alias = model
.get_attr("alias")
.ok()
.and_then(|v| v.as_str().map(|s| s.to_string()))
.unwrap_or_default();
// Get python_version from config, default to "3.11"
let python_version = config
.get_attr("python_version")
.ok()
.and_then(|v| v.as_str().map(|s| s.to_string()))
.unwrap_or_else(|| "3.11".to_string());
View on GitHub (pinned to 0267ce9170)