astrid-runtime/astrid · error
Cargo include optional must be a boolean in {}
Error message
Cargo include optional must be a boolean in {} What it means
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.
Source
Thrown at crates/astrid-build/src/rust/config.rs:239
return array
.iter()
.map(|value| {
if let Some(include) = value.as_str() {
Ok(resolve_cargo_config_include(path, include, false)?)
} else if let Some(table) = value.as_inline_table() {
let include = table
.get("path")
.and_then(toml_edit::Value::as_str)
.ok_or_else(|| {
anyhow::anyhow!(
"Cargo include table must contain a string path in {}",
path.display()
)
})?;
let optional = match table.get("optional") {
None => false,
Some(value) => value.as_bool().ok_or_else(|| {
anyhow::anyhow!(
"Cargo include optional must be a boolean in {}",
path.display()
)
})?,
};
Ok(resolve_cargo_config_include(path, include, optional)?)
} else {
bail!(
"Cargo include array contains a non-string or non-table value in {}",
path.display()
)
}
})
.collect();
}
if let Some(table) = item.as_table_like() {
let include = table
.get("path")View on GitHub (pinned to affd8760f4)
Solutions
- Change `optional` to an unquoted boolean: `optional = true`
- Remove the `optional` key entirely to use the default (false)
Example fix
# before
include = { path = "x.toml", optional = "true" }
# after
include = { path = "x.toml", optional = true } Defensive patterns
Strategy: validation
Validate before calling
fn validate_optional_flag(t: &toml::Value) -> Result<(), String> {
match t.get("optional") {
None | Some(toml::Value::Boolean(_)) => Ok(()),
Some(_) => Err("`optional` must be a boolean".into()),
}
} Type guard
fn optional_is_bool(t: &toml::Value) -> bool {
matches!(t.get("optional"), None | Some(toml::Value::Boolean(_)))
} Try / catch
match load_content(...) {
Err(e) if e.to_string().contains("optional must be a boolean") => {
eprintln!("use unquoted true/false for `optional`");
}
other => other?,
} Prevention
- Never quote booleans in TOML
- Lint config files with a TOML validator
- Avoid translating `yes/no` style values from YAML into TOML
When it happens
Trigger: 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.
Common situations: Quoting booleans by habit from other config formats (JSON/YAML strings); mistyping `optional = 1`.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- existing [security.capsule_local_egress].{capsule_id} is not
- Cargo include table must contain a string path in {}
- Cargo rustflags array contains a non-string value in {}
- No Cargo build target selected. Set `[build] target = "wasm3
- Capsule.toml has no package.name
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/1672acfefb4b6438.
Report an issue: GitHub.