dbt-labs/dbt-core · error · syn::Error
Failed to parse value of `{field}` as path.
Error message
Failed to parse value of `{field}` as path. What it means
Raised by parse_path in crates/dbt-runtime-macros/src/entry.rs when the attribute option's value is not a string literal at all. parse_path only handles `syn::Lit::Str`; any other literal kind (integer, bool, byte string, etc.) passed to a path-valued option produces this error at compile time.
Source
Thrown at crates/dbt-runtime-macros/src/entry.rs:306
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 {
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 {View on GitHub (pinned to 0267ce9170)
Solutions
- Wrap the value in double quotes so it is a string literal: `crate = "my_crate"`
- Ensure the option expects a path and you are passing a quoted path, not an identifier or number
- Re-read the macro documentation for the exact expected value syntax
Example fix
// before #[dbt::main(crate = my_crate)] // after #[dbt::main(crate = "my_crate")]
Defensive patterns
Strategy: validation
Validate before calling
// ensure the option value is a quoted string literal before handing it to the macro
// attribute check: value must start and end with double quotes
fn is_quoted_string(raw: &str) -> bool {
raw.starts_with('"') && raw.ends_with('"') && raw.len() >= 2
}
// e.g. attribute should read: crate = "my_crate" Prevention
- Quote every macro attribute value: `crate = "name"`, never a bare token
- Do not pass numbers or booleans to path/string options
- Review macro docs for which options take paths vs strings vs bools
When it happens
Trigger: Passing a non-string literal to a path-valued macro option, e.g. `crate = 123`, `crate = true`, or an unquoted bareword that syn lexes as a non-string literal.
Common situations: Forgetting the quotes around the crate/path value in a `#[...]` attribute; writing `crate = my_crate` instead of `crate = "my_crate"`; IDE auto-completion inserting an unquoted token.
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.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse value of `{field}` as integer.
- Failed to parse value of `{field}` as string.
- Failed to parse value of `{field}` as path: "{path}"
- Failed to parse value of `{field}` as bool.
- Unsupported enum field type shape; expected i32, Option<i32>
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/c273a5d0c81e469a.
Report an issue: GitHub.