Hmbown/CodeWhale · error

Profile ' ' not found. Available profiles

Error message

Profile '{profile_name}' not found. Available profiles: {available}

What it means

Profile resolution looks up profile_name in the configured profiles map; if the containing table exists but the key does not, it bails listing all available profile keys so the user can pick a valid one. Configs without a profiles table fall through to the base profile instead of erroring.

Solutions

  1. Use one of the profile names listed in the error message
  2. Fix the spelling in your --profile flag or script
  3. Add the missing [profiles.<name>] table to ~/.codewhale/config.toml
  4. Omit --profile to use the base configuration

Example fix

// before (config.toml has only [profiles.work])
codewhale --profile prod
// after
codewhale --profile work
# or add:
# [profiles.prod]
# base = "work"
Defensive patterns

Strategy: validation

Validate before calling

// check the profile exists in config.toml before passing --profile
let cfg = std::fs::read_to_string("~/.codewhale/config.toml")?;
if !cfg.contains(&format!("[profiles.{name}]")) {
    eprintln!("profile '{name}' not defined in config.toml");
}

Try / catch

match result {
    Err(e) if e.to_string().contains("not found. Available profiles") => eprintln!("pick one of the listed profiles or add [profiles.<name>] to config.toml"),
    other => other?,
}

Prevention

When it happens

Trigger: Requesting --profile <name> (or profile resolution via config) where the profiles table exists but does not contain that key; the error lists the valid keys, or 'none' when the table is empty.

Common situations: Typo in the profile name; renaming a profile in config.toml while scripts/CI still pass the old name; running on a machine whose config lacks the profile defined elsewhere.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/config.rs:11156

        match profiles.and_then(|profiles| profiles.get(profile_name)) {
            Some(override_cfg) => {
                let mut merged = merge_config(*config.base, override_cfg.clone());
                apply_layer_root_model(&mut merged, override_cfg);
                Ok(merged)
            }
            None => {
                let available = profiles
                    .map(|profiles| {
                        let mut keys = profiles.keys().cloned().collect::<Vec<_>>();
                        keys.sort();
                        if keys.is_empty() {
                            "none".to_string()
                        } else {
                            keys.join(", ")
                        }
                    })
                    .unwrap_or_else(|| "none".to_string());
                anyhow::bail!("Profile '{profile_name}' not found. Available profiles: {available}")
            }
        }
    } else {
        Ok(*config.base)
    }
}

fn merge_config(base: Config, override_cfg: Config) -> Config {
    // Captured before the struct literal moves the field out of `override_cfg`.
    let override_defines_root_base_url = override_cfg.base_url.is_some();
    Config {
        custom_models: override_cfg.custom_models.or(base.custom_models),
        provider: override_cfg.provider.or(base.provider),
        telemetry: override_cfg.telemetry.or(base.telemetry),
        api_key: override_cfg.api_key.or(base.api_key),
        base_url: override_cfg.base_url.or(base.base_url),
        http_headers: override_cfg.http_headers.or(base.http_headers),
        default_text_model: override_cfg

View on GitHub (pinned to 73e0f67d83)