{"record":{"id":"64c1849a6ea29bb5","repo":"astrid-runtime/astrid","slug":"cargo-rustflags-array-contains-a-non-string-value","errorCode":null,"errorMessage":"Cargo rustflags array contains a non-string value in {}","messagePattern":"Cargo rustflags array contains a non-string value in (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-build/src/rust/config.rs","lineNumber":406,"sourceCode":"        Ok(content) => Ok(Some(content)),\n        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(None),\n        Err(error) => Err(error)\n            .with_context(|| format!(\"Failed to read Cargo configuration {}\", path.display())),\n    }\n}\n\nstruct ParsedRustflags {\n    flags: Vec<String>,\n    is_array: bool,\n}\n\nfn parse_rustflags(item: &toml_edit::Item, path: &Path) -> Result<ParsedRustflags> {\n    if let Some(array) = item.as_array() {\n        let flags = array\n            .iter()\n            .map(|value| {\n                value.as_str().map(str::to_owned).ok_or_else(|| {\n                    anyhow::anyhow!(\n                        \"Cargo rustflags array contains a non-string value in {}\",\n                        path.display()\n                    )\n                })\n            })\n            .collect::<Result<Vec<_>>>()?;\n        return Ok(ParsedRustflags {\n            flags,\n            is_array: true,\n        });\n    }\n    if let Some(value) = item.as_str() {\n        return Ok(ParsedRustflags {\n            flags: value.split_whitespace().map(str::to_owned).collect(),\n            is_array: false,\n        });\n    }\n    bail!(","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-build/src/rust/config.rs#L388-L424","documentation":"Array element validation in parse_rustflags: the rustflags value is an array, but one of its elements is not a string (e.g. an integer or nested array). Each array element must be an individual compiler flag string; a non-string element makes the flag list uninterpretable and absorb_document aborts naming the config file.","triggerScenarios":"absorb_document parsing `[build]\\nrustflags = [\"-C\", \"target-feature=+atomics\", 42]` — any non-string array element triggers the error.","commonSituations":"Unquoted numeric-looking flags (e.g. -C link-arg=-O2 values left bare), copy-paste from JSON where numbers weren't quoted, mixing flags arrays with scalar forms.","solutions":["Quote every element of the rustflags array","Remove or stringify non-string elements","Alternatively use the string form `rustflags = \"flag1 flag2\"` if supported"],"exampleFix":"# before\n[build]\nrustflags = [\"-C\", \"target-cpu\", 4]\n# after\n[build]\nrustflags = [\"-C\", \"target-cpu=native\"]","handlingStrategy":"validation","validationCode":"fn validate_rustflags(item: &toml_edit::Item) -> Result<(), String> {\n    if let Some(arr) = item.as_array() {\n        for v in arr.iter() {\n            if v.as_str().is_none() {\n                return Err(\"all rustflags array elements must be strings\".into());\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn rustflags_all_strings(item: &toml_edit::Item) -> bool {\n    item.as_array().map_or(true, |a| {\n        a.iter().all(|v| v.as_str().is_some())\n    })\n}","tryCatchPattern":"match absorb_document(...) {\n    Err(e) if e.to_string().contains(\"rustflags array contains a non-string\") => {\n        eprintln!(\"quote every element in the rustflags array\");\n    }\n    other => other?,\n}","preventionTips":["Quote every rustflags array element, including flag values","Prefer the string form rustflags = \"-C ...\" when mixing sources","Lint .cargo/config.toml arrays for mixed types"],"tags":["toml","cargo","rustflags","type-mismatch"],"backgroundTag":"invalid-config-value","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}