Hmbown/CodeWhale · error

key not found

Error message

key not found: {key}

What it means

The `codewhale config get <key>` command resolves a key either through route preferences or notification settings; if the key is a valid route key but has no stored value (get returns None), the command aborts with this error. It signals the user asked to read a config key that has never been set.

Solutions

  1. Run `codewhale config set <key> <value>` to create the value, then get it again.
  2. List available keys (e.g. `codewhale config doctor` or dump) to confirm the key name and whether it is expected to have a value.
  3. Check that the store preferences file at store.path() exists and was not wiped.

Example fix

// before
codewhale config get model
// after
codewhale config set model <model-name> && codewhale config get model
Defensive patterns

Strategy: validation

Validate before calling

if codewhale_tui::route_preferences::is_route_key(&key) && codewhale_tui::route_preferences::get(store.path(), &key)?.is_none() {
    eprintln!("key '{key}' is not set yet; run 'codewhale config set {key} <value>' first");
}

Try / catch

match result {
    Err(e) if e.to_string().starts_with("key not found") => {
        eprintln!("not set yet — set it first with 'codewhale config set'");
    }
    Err(e) => return Err(e),
    Ok(v) => println!("{v}"),
}

Prevention

When it happens

Trigger: Running `codewhale config get <route-key>` when `route_preferences::get` returns Ok(None) — i.e. the key is recognized as a route key but no preference was ever persisted.

Common situations: Fresh installation with no saved route preferences; typo-free but never-set key such as `model` before any `config set model` call; reading a key after preferences file was deleted or reset.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/dea3bbf1b83a6854. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/lib.rs:4505

                | ConfigCommand::Telemetry {
                    accept_notice: Some(_)
                }
        )
    {
        bail!(
            "--set is per-run and never saved; it cannot be combined with `config set`, \
             `config unset`, or `config import`. Drop --set, or use a read command."
        );
    }
    match command {
        ConfigCommand::Get { key } => {
            if per_run_overrides.is_empty() && codewhale_tui::route_preferences::is_route_key(&key)
            {
                if let Some(value) = codewhale_tui::route_preferences::get(store.path(), &key)? {
                    println!("{value}");
                    return Ok(());
                }
                bail!("key not found: {key}");
            }
            if codewhale_config::notifications::in_namespace(&key) {
                let config = codewhale_config::notifications::from_extras(&store.config.extras)?;
                let keys = if key.eq_ignore_ascii_case("notifications") {
                    codewhale_config::notifications::NotificationSetting::ALL.to_vec()
                } else {
                    vec![codewhale_config::notifications::NotificationSetting::required(&key)?]
                };
                for setting in keys {
                    if key.eq_ignore_ascii_case("notifications") {
                        println!(
                            "notifications.{} = {}",
                            setting.key(),
                            config.display(setting)
                        );
                    } else {
                        println!("{}", config.display(setting));
                    }

View on GitHub (pinned to 73e0f67d83)