dbt-labs/dbt-core · error

unset_constraints should be iterable

Error message

unset_constraints should be iterable

What it means

Test-only assertion in test_constraints_to_jinja_exposes_object_attributes: the value of the `unset_constraints` attribute must be iterable so templates can loop over constraints. Fires only if the Jinja representation of the constraints set stops supporting iteration.

Solutions

  1. Ensure unset_constraints is rendered as a Jinja sequence object implementing try_iter
  2. Check the object type returned for unset_constraints in to_jinja
  3. Treat failure as a regression in the Jinja constraints wrapper
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/dbt-adapter/src/relation/databricks/config/components/constraints.rs:953 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/0f69fc8c67c9cf42. Report an issue: GitHub.

Appendix: source

Thrown at crates/dbt-adapter/src/relation/databricks/config/components/constraints.rs:953

        let pk = TypedConstraint::PrimaryKey {
            name: Some("pk_id".to_string()),
            columns: vec!["id".to_string()],
            expression: None,
        };
        let constraints = Constraints::new(
            IndexSet::new(),
            IndexSet::new(),
            IndexSet::new(),
            IndexSet::from([pk]),
        );

        let jinja_val = constraints.to_jinja();
        let unset = jinja_val
            .get_attr("unset_constraints")
            .expect("unset_constraints should be accessible");
        let mut iter = unset
            .try_iter()
            .expect("unset_constraints should be iterable");
        let constraint_val = iter.next().expect("should have one constraint");

        let type_val = constraint_val
            .get_attr("type")
            .expect("type should be accessible");
        assert_eq!(type_val.as_str(), Some("primary_key"));

        let name_val = constraint_val
            .get_attr("name")
            .expect("name should be accessible");
        assert_eq!(name_val.as_str(), Some("pk_id"));

        let render_val = constraint_val
            .get_attr("render")
            .expect("render should be accessible");
        assert!(
            !render_val.is_undefined(),
            "render should be a callable function"

View on GitHub (pinned to 0267ce9170)