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

Failed to parse value of `{field}` as path: "{path}"

Error message

Failed to parse value of `{field}` as path: "{path}"

What it means

This compile-time error comes from a proc-macro attribute parser (tokio-style entry macro) in crates/dbt-runtime-macros/src/entry.rs. When an attribute option's value (e.g. `crate = "..."`) is a string literal, it is parsed as a Rust path (`syn::Path`); if the string is not syntactically a valid Rust path, the macro throws this error and compilation fails before any code runs.

Source

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

        )),
    }
}

fn parse_string(int: syn::Lit, span: Span, field: &str) -> Result<String, syn::Error> {
    match int {
        syn::Lit::Str(s) => Ok(s.value()),
        syn::Lit::Verbatim(s) => Ok(s.to_string()),
        _ => Err(syn::Error::new(
            span,
            format!("Failed to parse value of `{field}` as string."),
        )),
    }
}

fn parse_path(lit: syn::Lit, span: Span, field: &str) -> Result<Path, syn::Error> {
    match lit {
        syn::Lit::Str(s) => {
            let err = syn::Error::new(
                span,
                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 {

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Make the string a valid Rust path: plain identifier or `::`-separated segments, e.g. `crate = "my_crate"`
  2. Check for typos, spaces, or special characters in the attribute value
  3. Use the raw identifier form if the crate name has unusual characters (e.g. `r#type`)
  4. If you did not intend to override the crate, remove the attribute option entirely

Example fix

// before
#[dbt::main(crate = "my crate")]
// after
#[dbt::main(crate = "my_crate")]
Defensive patterns

Strategy: validation

Validate before calling

// validate at authoring time: the attribute value must be a valid Rust path
fn is_valid_rust_path(s: &str) -> bool {
    !s.is_empty()
        && s.split("::").all(|seg| {
            let seg = seg.trim_start_matches("r#");
            !seg.is_empty()
                && seg.chars().next().map_or(false, |c| c.is_alphabetic() || c == '_')
                && seg.chars().all(|c| c.is_alphanumeric() || c == '_')
        })
}
// assert!(is_valid_rust_path("my_crate"));

Prevention

When it happens

Trigger: Writing a macro attribute with a `crate = "..."` (or similar path-valued) option whose string cannot be parsed by `syn` as a `syn::Path`, e.g. containing invalid identifiers, leading/trailing punctuation, or spaces like `crate = "my crate"`.

Common situations: Typo or non-identifier characters in the `crate` option of `#[tokio::main]`-style or dbt entry attributes; renaming a crate and leaving stale/invalid path syntax; copy-pasting a path with quotes inside quotes or whitespace.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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