{"record":{"id":"1672acfefb4b6438","repo":"astrid-runtime/astrid","slug":"cargo-include-optional-must-be-a-boolean-in","errorCode":null,"errorMessage":"Cargo include optional must be a boolean in {}","messagePattern":"Cargo include optional must be a boolean in (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-build/src/rust/config.rs","lineNumber":239,"sourceCode":"        return array\n            .iter()\n            .map(|value| {\n                if let Some(include) = value.as_str() {\n                    Ok(resolve_cargo_config_include(path, include, false)?)\n                } else if let Some(table) = value.as_inline_table() {\n                    let include = table\n                        .get(\"path\")\n                        .and_then(toml_edit::Value::as_str)\n                        .ok_or_else(|| {\n                            anyhow::anyhow!(\n                                \"Cargo include table must contain a string path in {}\",\n                                path.display()\n                            )\n                        })?;\n                    let optional = match table.get(\"optional\") {\n                        None => false,\n                        Some(value) => value.as_bool().ok_or_else(|| {\n                            anyhow::anyhow!(\n                                \"Cargo include optional must be a boolean in {}\",\n                                path.display()\n                            )\n                        })?,\n                    };\n                    Ok(resolve_cargo_config_include(path, include, optional)?)\n                } else {\n                    bail!(\n                        \"Cargo include array contains a non-string or non-table value in {}\",\n                        path.display()\n                    )\n                }\n            })\n            .collect();\n    }\n    if let Some(table) = item.as_table_like() {\n        let include = table\n            .get(\"path\")","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-build/src/rust/config.rs#L221-L257","documentation":"Schema validation in cargo_config_includes: an include given as an inline table has an `optional` key whose value is not a boolean (e.g. a string \"true\" or an integer). TOML requires optional to be a real bool for the include semantics to be well-defined; load_content aborts and names the config file so the type error can be fixed.","triggerScenarios":"load_content parsing `.cargo/config.toml` with an inline table like `include = { path = \"x.toml\", optional = \"true\" }` (string instead of boolean) at the inline-table branch.","commonSituations":"Quoting booleans by habit from other config formats (JSON/YAML strings); mistyping `optional = 1`.","solutions":["Change `optional` to an unquoted boolean: `optional = true`","Remove the `optional` key entirely to use the default (false)"],"exampleFix":"# before\ninclude = { path = \"x.toml\", optional = \"true\" }\n# after\ninclude = { path = \"x.toml\", optional = true }","handlingStrategy":"validation","validationCode":"fn validate_optional_flag(t: &toml::Value) -> Result<(), String> {\n    match t.get(\"optional\") {\n        None | Some(toml::Value::Boolean(_)) => Ok(()),\n        Some(_) => Err(\"`optional` must be a boolean\".into()),\n    }\n}","typeGuard":"fn optional_is_bool(t: &toml::Value) -> bool {\n    matches!(t.get(\"optional\"), None | Some(toml::Value::Boolean(_)))\n}","tryCatchPattern":"match load_content(...) {\n    Err(e) if e.to_string().contains(\"optional must be a boolean\") => {\n        eprintln!(\"use unquoted true/false for `optional`\");\n    }\n    other => other?,\n}","preventionTips":["Never quote booleans in TOML","Lint config files with a TOML validator","Avoid translating `yes/no` style values from YAML into TOML"],"tags":["toml","config","cargo","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"}