astrid-runtime/astrid · error

--var names no [env] field in {}: {key}

Error message

--var names no [env] field in {}: {key}

What it means

After parsing `--var` items, `validate_values` checks each key against the capsule manifest's `[env]` table. Any key that is not declared in the manifest is rejected, because the daemon only injects env vars the capsule explicitly declares (typed and manifest-bound).

Source

Thrown at crates/astrid-cli/src/commands/capsule/install_daemon.rs:427

    items: &[String],
) -> anyhow::Result<Vec<DaemonEnvValue>> {
    let mut parsed = HashMap::new();
    for item in items {
        let (key, value) = item
            .split_once('=')
            .ok_or_else(|| anyhow::anyhow!("--var must be KEY=VALUE (got {item:?})"))?;
        if key.is_empty() || key.contains('\0') || key.contains(':') {
            bail!("--var has an invalid key (got {key:?})");
        }
        if parsed.insert(key.to_owned(), value.to_owned()).is_some() {
            bail!("--var '{key}' was supplied more than once");
        }
    }

    let mut values = Vec::with_capacity(parsed.len());
    for (key, value) in parsed {
        let definition = manifest.env.get(&key).ok_or_else(|| {
            anyhow::anyhow!(
                "--var names no [env] field in {}: {key}",
                manifest.package.name
            )
        })?;
        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

View on GitHub (pinned to affd8760f4)

Solutions

  1. Check the capsule manifest `[env]` section and use an exact declared key name
  2. Remove the `--var` if it is not needed by this capsule
  3. Update scripts after capsule manifest key renames

Example fix

// before (manifest [env] declares LOG_LEVEL, not LOGLEVEL)
--var LOGLEVEL=debug
// after
--var LOG_LEVEL=debug
Defensive patterns

Strategy: validation

Validate before calling

// Read the capsule manifest and check keys before install:
// let declared: HashSet<_> = manifest.env.keys().collect();
// let ok = var_keys.iter().all(|k| declared.contains(*k));

Try / catch

match result {
    Err(e) if e.to_string().starts_with("--var names no [env] field") => {
        eprintln!("Key not declared in capsule manifest [env]; check spelling and manifest version.");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling `validate_values` (via daemon local install) with a `--var` key absent from the capsule manifest's `[env]` section — typo'd key, deprecated/renamed key, or a var belonging to a different capsule.

Common situations: Renaming an env field in the manifest while scripts still pass the old name; copying install commands between different capsules; guessing var names instead of reading the manifest's `[env]` section.

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


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/867f63e418a1558e. Report an issue: GitHub.