Hmbown/CodeWhale · error

agent profile provider cannot be empty

Error message

agent profile {} provider cannot be empty

What it means

Agent profile TOML files must name a provider id explicitly. validate_agent_profile_provider in crates/tui/src/fleet/profile.rs rejects a provider value that is empty or whitespace-only, because the field is the ONLY place a profile's provider is established — callers never infer it from the model name (EPIC #2608).

Solutions

  1. Set a non-empty `provider = "<provider-id>"` in the profile TOML
  2. Use a simple provider id that exists in the session config so `[providers.<id>]` resolves at launch
  3. Re-run agent_profile_from_toml after fixing the file

Example fix

# before
provider = ""
# after
provider = "anthropic"
Defensive patterns

Strategy: validation

Validate before calling

fn provider_ok(v: Option<&str>) -> bool { v.map(|s| !s.trim().is_empty()).unwrap_or(false) }
assert!(provider_ok(Some("anthropic")));
assert!(!provider_ok(Some("")));

Type guard

fn has_provider(p: &AgentProfileToml) -> bool { p.provider.as_deref().map(|s| !s.trim().is_empty()).unwrap_or(false) }

Try / catch

match agent_profile_from_toml(path) {
    Ok(p) => p,
    Err(e) if e.to_string().contains("provider cannot be empty") => {
        eprintln!("{}: add a non-empty `provider` key", path.display());
        return;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling agent_profile_from_toml on a profile whose `provider` key is missing/empty or set to "" or whitespace; validation happens at crates/tui/src/fleet/profile.rs:559.

Common situations: Hand-written fleet profile TOML that omits `provider`; copy-pasting a profile and deleting the provider line assuming the model string implies it; templating tools emitting blank provider values.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/fleet/profile.rs:559

        bail!(
            "agent profile {} model must be a visible model id without whitespace or secrets",
            path.display()
        );
    }
    Ok(())
}

/// Validate an explicit `provider` field as a safe provider id (#4093).
///
/// Built-in providers are accepted by the runtime vocabulary, and user-named
/// OpenAI-compatible custom providers are accepted as simple tokens so the
/// launch path can resolve `[providers.<id>]` from the session config (#3965).
/// This field remains the ONLY place a profile's provider is established:
/// callers never infer it from `model` (EPIC #2608).
fn validate_agent_profile_provider(path: &Path, value: &str) -> Result<()> {
    let trimmed = value.trim();
    if trimmed.is_empty() {
        bail!("agent profile {} provider cannot be empty", path.display());
    }
    if trimmed != value || !trimmed.chars().all(is_agent_profile_token_char) {
        bail!(
            "agent profile {} provider must be a simple provider id",
            path.display()
        );
    }
    Ok(())
}

fn normalize_agent_profile_reasoning_effort(
    path: &Path,
    value: Option<&str>,
) -> Result<Option<String>> {
    let Some(value) = non_empty_trimmed(value) else {
        return Ok(None);
    };
    if matches!(

View on GitHub (pinned to 73e0f67d83)