dbt-labs/dbt-core · error

key must be a string

Error message

key must be a string

What it means

The 'get' method on the RelationComponentConfigChangeSet Jinja object requires its key argument to be a string; as_str() returned None because a number/object/sequence was passed (e.g. changes.get(tags) without quotes).

Solutions

  1. Pass the key as a string literal, e.g. _configuration_changes.changes.get('tags', None)
  2. Quote the key in the template
  3. Coerce non-string keys with |string where appropriate
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/dbt-adapter/src/relation/config_v2.rs:658 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/70502e12f30859af. Report an issue: GitHub.

Appendix: source

Thrown at crates/dbt-adapter/src/relation/config_v2.rs:658

    }
}

impl Object for RelationComponentConfigChangeSet {
    fn call_method(
        self: &Arc<Self>,
        _state: &minijinja::State,
        name: &str,
        args: &[Value],
        _listeners: &[Rc<dyn RenderingEventListener>],
    ) -> Result<Value, minijinja::Error> {
        // TODO: ArgsIter
        let mut parser = ArgParser::new(args, None);
        match name {
            // support example `_configuration_changes.changes.get("tags", None)`
            "get" => {
                let key = parser.get::<Value>("key")?;
                let key = key.as_str().ok_or_else(|| {
                    minijinja::Error::new(
                        minijinja::ErrorKind::InvalidArgument,
                        "key must be a string",
                    )
                })?;

                Ok(self
                    .changes
                    .get(key)
                    .map(|v| v.to_jinja())
                    .unwrap_or_else(none_value))
            }
            "has_changes" => Ok(Value::from(!self.changes.is_empty())),
            "requires_full_refresh" => Ok(Value::from(self.requires_full_refresh())),
            _ => Err(minijinja::Error::new(
                minijinja::ErrorKind::UnknownMethod,
                format!("RelationComponentConfigChangeSet has no method named '{name}'"),
            )),
        }

View on GitHub (pinned to 0267ce9170)