astrid-runtime/astrid · error
invalid value for {}.{}: expected one of {}, got {value:?}
Error message
invalid value for {}.{}: expected one of {}, got {value:?} What it means
If the [env] definition in Capsule.toml declares enum_values, validate_values requires the supplied value to be one of them. Otherwise it bails listing the manifest/package name, the allowed values, and the offending value.
Source
Thrown at crates/astrid-cli/src/commands/capsule/install_daemon.rs:449
})?;
let kind = if definition.env_type.eq_ignore_ascii_case("secret") {
if value.len() > 64 * 1024 {
bail!("secret value for {key} exceeds 65536-byte limit");
}
EnvValueKind::Secret
} else {
if value.len() > 1 << 20 {
bail!("environment value for {key} exceeds 1048576-byte limit");
}
EnvValueKind::Text
};
if !definition.enum_values.is_empty()
&& !definition
.enum_values
.iter()
.any(|allowed| allowed == &value)
{
bail!(
"invalid value for {}.{}: expected one of {}, got {value:?}",
manifest.package.name,
key,
definition.enum_values.join(", "),
);
}
values.push(DaemonEnvValue { key, value, kind });
}
values.sort_by(|left, right| left.key.cmp(&right.key));
Ok(values)
}
#[cfg(test)]
mod tests {
use super::*;
fn identity(digest: &str, generation: InstalledCapsuleGeneration) -> InstalledCapsuleIdentity {
InstalledCapsuleIdentity {View on GitHub (pinned to affd8760f4)
Solutions
- Use one of the allowed values listed in the error message exactly.
- Check the [env.KEY] enum_values in Capsule.toml for the accepted set and casing.
- Update scripts/configs after a manifest change that altered the enum.
- If the value is legitimately new, extend enum_values in Capsule.toml.
Example fix
// before --var LOG_LEVEL=verbose // after (enum_values = ["debug", "info", "warn", "error"]) --var LOG_LEVEL=info
Defensive patterns
Strategy: validation
Validate before calling
// parse enum_values from Capsule.toml [env.KEY] and check membership before install
assert!(enum_values.contains(&value), "invalid value for {key}"); Try / catch
on this error, print the allowed set from the message and abort the script so the operator corrects the value.
Prevention
- Generate --var values from the manifest's enum_values, not free text.
- Re-validate scripts after any Capsule.toml enum change.
- Match enum casing exactly as declared.
When it happens
Trigger: Passing --var KEY=value where definition.enum_values is non-empty and no entry equals the supplied value, during install_local_via_daemon_for_target_with_generation.
Common situations: Typo in a enum-constrained value (e.g. `--var LOG_LEVEL=infoo`); case mismatch; manifest enum tightened in a newer capsule version while scripts still pass old values.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- --var has an invalid key (got {key:?})
- environment value for {key} exceeds 1048576-byte limit
- --var names no [env] field in {}: {key}
- --retain-entries must be at least 1
- --retain-bytes must be greater than 0
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/6b43cca992c4a4fd.
Report an issue: GitHub.