{"record":{"id":"2ff47ffce0e69de1","repo":"dbt-labs/dbt-core","slug":"failed-to-parse-value-of-field-as-string","errorCode":null,"errorMessage":"Failed to parse value of `{field}` as string.","messagePattern":"Failed to parse value of `(.+?)` as string\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/dbt-runtime-macros/src/entry.rs","lineNumber":286,"sourceCode":"        syn::Lit::Int(lit) => match lit.base10_parse::<usize>() {\n            Ok(value) => Ok(value),\n            Err(e) => Err(syn::Error::new(\n                span,\n                format!(\"Failed to parse value of `{field}` as integer: {e}\"),\n            )),\n        },\n        _ => Err(syn::Error::new(\n            span,\n            format!(\"Failed to parse value of `{field}` as integer.\"),\n        )),\n    }\n}\n\nfn parse_string(int: syn::Lit, span: Span, field: &str) -> Result<String, syn::Error> {\n    match int {\n        syn::Lit::Str(s) => Ok(s.value()),\n        syn::Lit::Verbatim(s) => Ok(s.to_string()),\n        _ => Err(syn::Error::new(\n            span,\n            format!(\"Failed to parse value of `{field}` as string.\"),\n        )),\n    }\n}\n\nfn parse_path(lit: syn::Lit, span: Span, field: &str) -> Result<Path, syn::Error> {\n    match lit {\n        syn::Lit::Str(s) => {\n            let err = syn::Error::new(\n                span,\n                format!(\n                    \"Failed to parse value of `{}` as path: \\\"{}\\\"\",\n                    field,\n                    s.value()\n                ),\n            );\n            s.parse::<syn::Path>().map_err(|_| err.clone())","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-runtime-macros/src/entry.rs#L268-L304","documentation":"Raised by the `parse_string` helper in crates/dbt-runtime-macros/src/entry.rs when a string-valued attribute option — `name`, `flavor`, or `unhandled_panic` (per the setters `set_name`, `set_flavor`, `set_unhandled_panic`) — is given a literal that is neither a string literal nor a verbatim token, e.g. an integer or bool literal. The macro rejects it at expansion time naming the offending field.","triggerScenarios":"Writing `name = 42`, `flavor = multi_thread` (unquoted identifier) or `unhandled_panic = true` in the attribute; anything that is not syn::Lit::Str or syn::Lit::Verbatim reaching `parse_string`.","commonSituations":"Forgetting quotes around enum-like values (`flavor = multi_thread` instead of `flavor = \"multi_thread\"`); passing a boolean to unhandled_panic instead of the string `\"abort_runtime\"`; templated attributes substituting unquoted values.","solutions":["Quote the value: `flavor = \"multi_thread\"`, `name = \"my_task\"`, `unhandled_panic = \"abort_runtime\"`.","For `unhandled_panic`, use the string literal form of the enum value, not a bare bool or identifier.","If a codegen tool emits the attribute, ensure string fields are emitted as quoted literals."],"exampleFix":"// before\n#[dbt_runtime::main(flavor = multi_thread)]\nasync fn main() { /* ... */ }\n\n// after\n#[dbt_runtime::main(flavor = \"multi_thread\")]\nasync fn main() { /* ... */ }","handlingStrategy":"validation","validationCode":"// String options (name, flavor, unhandled_panic) require quoted literals.\n#[dbt_runtime::main(\n    name = \"svc\",\n    flavor = \"multi_thread\",\n)]\nasync fn main() {}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote string-valued attribute options; bare identifiers like `flavor = multi_thread` fail.","unhandled_panic takes a string value like \"abort_runtime\", not a bool.","If attributes are generated, validate that string fields are emitted with quotes."],"tags":["rust","macros","compile-time","type-mismatch","attribute"],"backgroundTag":"type-mismatch","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}