dbt-labs/dbt-core · error · syn::Error
Failed to parse value of `{field}` as integer.
Error message
Failed to parse value of `{field}` as integer. What it means
Raised by the `parse_int` helper in crates/dbt-runtime-macros/src/entry.rs when an integer-valued attribute option (e.g. `worker_threads`) is given a literal that is not an integer at all — anything other than syn::Lit::Int, such as a string or bool literal. The macro rejects it at expansion time with a plain message naming the field.
Source
Thrown at crates/dbt-runtime-macros/src/entry.rs:275
crate_name: self.crate_name.clone(),
flavor,
worker_threads,
start_paused,
unhandled_panic,
})
}
}
fn parse_int(int: syn::Lit, span: Span, field: &str) -> Result<usize, syn::Error> {
match int {
syn::Lit::Int(lit) => match lit.base10_parse::<usize>() {
Ok(value) => Ok(value),
Err(e) => Err(syn::Error::new(
span,
format!("Failed to parse value of `{field}` as integer: {e}"),
)),
},
_ => Err(syn::Error::new(
span,
format!("Failed to parse value of `{field}` as integer."),
)),
}
}
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> {View on GitHub (pinned to 0267ce9170)
Solutions
- Remove the quotes: use an unquoted integer literal, e.g. `worker_threads = 4`.
- Ensure the field you set is one that expects an integer; string-valued options (name, flavor, unhandled_panic) should not use parse_int fields.
- Check codegen/config templating so numeric values are emitted unquoted.
Example fix
// before
#[dbt_runtime::main(worker_threads = "4")]
async fn main() { /* ... */ }
// after
#[dbt_runtime::main(flavor = "multi_thread", worker_threads = 4)]
async fn main() { /* ... */ } Defensive patterns
Strategy: validation
Validate before calling
// Integer options must be unquoted integer literals in the attribute.
// WRONG: #[dbt_runtime::main(worker_threads = "4")]
// RIGHT:
#[dbt_runtime::main(flavor = "multi_thread", worker_threads = 4)]
async fn main() {} Prevention
- Never quote numeric attribute values.
- Check templating/codegen output so numeric fields are emitted as bare literals.
- Only use integer literals on integer options (worker_threads); strings go to name/flavor/unhandled_panic.
When it happens
Trigger: Writing `worker_threads = "8"` (string instead of integer literal) or `worker_threads = true` in the attribute; passing any non-Int literal to a field parsed by `parse_int` via `set_worker_threads`.
Common situations: Quoting numeric attribute values out of habit; generating attributes from config where the value was serialized as a string; editing an attribute and accidentally adding quotes.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 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 string.
- Failed to parse value of `{field}` as integer: {e}
- The `start_paused` option requires the `current_thread` runt
- The `unhandled_panic` option requires the `current_thread` r
- Failed to parse value of `{field}` as path.
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/e7ad0a9c84cb6a1b.
Report an issue: GitHub.