dbt-labs/dbt-core · error · minijinja::Error

unsupported numeric type for version

Error message

unsupported numeric type for version

What it means

This minijinja error is thrown by NodeVersion's TryFrom<Value> conversion in crates/dbt-schemas/src/schemas/serde.rs. When the version value is numeric, the code first tries integers, then falls back to `f64::try_from(value)`; if neither works (e.g. a numeric type that cannot be represented as f64, such as very large integers), it reports 'unsupported numeric type for version'.

Source

Thrown at crates/dbt-schemas/src/schemas/serde.rs:772

    fn try_from(value: minijinja::Value) -> Result<Self, Self::Error> {
        match value.kind() {
            ValueKind::String => Ok(NodeVersion::String(
                value
                    .as_str()
                    .expect("kind is String but as_str returned None")
                    .to_owned(),
            )),
            ValueKind::Number => {
                if value.is_integer() {
                    if let Some(i) = value.as_i64() {
                        return Ok(NodeVersion::Integer(i));
                    }
                }
                if let Ok(f) = f64::try_from(value) {
                    Ok(NodeVersion::Float(f))
                } else {
                    Err(minijinja::Error::new(
                        minijinja::ErrorKind::InvalidOperation,
                        "unsupported numeric type for version",
                    ))
                }
            }
            _ => Err(minijinja::Error::new(
                minijinja::ErrorKind::InvalidOperation,
                "version must be a string, integer, or float",
            )),
        }
    }
}

#[derive(Debug, Serialize, UntaggedEnumDeserialize, Clone, PartialEq, Eq, DbtSchema)]
#[serde(untagged)]
pub enum StringOrMap {
    StringValue(String),
    MapValue(HashMap<String, YmlValue>),

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Change the version value to a normal integer within i64/u64 range, or a finite float
  2. Quote the version to make it a string, e.g. `version: '2.0'`, which takes the string branch
  3. Inspect the rendered value in your template to confirm what numeric type it produces
  4. Round or clamp oversized numbers in upstream config before they reach serialization

Example fix

# before
version: 99999999999999999999999999
# after
version: '2.0'
Defensive patterns

Strategy: type-guard

Validate before calling

import math

def is_safe_numeric_version(v):
    if isinstance(v, bool):
        return False
    if isinstance(v, int):
        return -(2**63) <= v <= 2**64 - 1
    if isinstance(v, float):
        return math.isfinite(v)
    return False
# guard before emitting a numeric version into templates

Type guard

import math

def as_node_version(v):
    if isinstance(v, bool):
        return None
    if isinstance(v, int) and -(2**63) <= v <= 2**64 - 1:
        return v
    if isinstance(v, float) and math.isfinite(v):
        return v
    if isinstance(v, str):
        return v
    return None

Try / catch

try:
    node_version = NodeVersion.try_from(value)
except Exception:
    # fall back to a string version, which always converts
    node_version = NodeVersion.try_from(str(value))

Prevention

When it happens

Trigger: Converting a minijinja Value whose numeric payload cannot be extracted as i64/u64 (that path failed) nor as f64 — e.g. an out-of-range or exotic numeric value assigned to a node's `version` field during deserialization.

Common situations: dbt model/resource `version` fields set to extremely large numbers or unusual numeric values in YAML; templated version values producing a numeric type outside supported ranges.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/d21c7d23f3e906bd. Report an issue: GitHub.