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

Failed to parse value of `{field}` as bool.

Error message

Failed to parse value of `{field}` as bool.

What it means

Raised by parse_bool in crates/dbt-runtime-macros/src/entry.rs when a boolean-valued macro attribute option (e.g. `start_paused`) receives a literal that is not a Rust `true`/`false` bool literal. The macro expects `syn::Lit::Bool` and rejects everything else at compile time.

Source

Thrown at crates/dbt-runtime-macros/src/entry.rs:316

                format!(
                    "Failed to parse value of `{}` as path: \"{}\"",
                    field,
                    s.value()
                ),
            );
            s.parse::<syn::Path>().map_err(|_| err.clone())
        }
        _ => Err(syn::Error::new(
            span,
            format!("Failed to parse value of `{field}` as path."),
        )),
    }
}

fn parse_bool(bool: syn::Lit, span: Span, field: &str) -> Result<bool, syn::Error> {
    match bool {
        syn::Lit::Bool(b) => Ok(b.value),
        _ => Err(syn::Error::new(
            span,
            format!("Failed to parse value of `{field}` as bool."),
        )),
    }
}

fn contains_impl_trait(ty: &syn::Type) -> bool {
    match ty {
        syn::Type::ImplTrait(_) => true,
        syn::Type::Array(t) => contains_impl_trait(&t.elem),
        syn::Type::Ptr(t) => contains_impl_trait(&t.elem),
        syn::Type::Reference(t) => contains_impl_trait(&t.elem),
        syn::Type::Slice(t) => contains_impl_trait(&t.elem),
        syn::Type::Tuple(t) => t.elems.iter().any(contains_impl_trait),
        syn::Type::Paren(t) => contains_impl_trait(&t.elem),
        syn::Type::Group(t) => contains_impl_trait(&t.elem),
        syn::Type::Path(t) => match t.path.segments.last() {
            Some(segment) => match &segment.arguments {

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Use an unquoted boolean literal: `start_paused = true` or `start_paused = false`
  2. Remove surrounding quotes if you wrote `"true"`
  3. Remember attribute values must be compile-time literals, not runtime expressions

Example fix

// before
#[dbt::main(start_paused = "true")]
// after
#[dbt::main(start_paused = true)]
Defensive patterns

Strategy: validation

Validate before calling

// boolean attribute options take bare literals, not quoted strings
fn is_valid_bool_attr(raw: &str) -> bool {
    raw == "true" || raw == "false"
}
// e.g. attribute should read: start_paused = true

Prevention

When it happens

Trigger: Writing `start_paused = "true"` (a string), `start_paused = 1`, or any non-bool literal on an attribute option that parse_bool handles via setters like set_start_paused.

Common situations: Quoting a boolean value by habit from config files; using 0/1 integer style; passing a runtime expression instead of a literal (proc-macro attributes only accept literals here).

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


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