Hmbown/CodeWhale · error

agent profile cannot be empty

Error message

agent profile {} {field} cannot be empty

What it means

validate_agent_profile_token enforces that profile token fields (id, name, model-family style values) are non-empty after trimming. An empty or whitespace-only value in a token field fails profile parsing with this error.

Solutions

  1. Set a non-empty value for the flagged field in the profile TOML
  2. If a template/script generates the file, fix the interpolation so the field is populated
  3. Remove the field if it is optional and you do not need it

Example fix

// before
id = ""

// after
id = "researcher"
Defensive patterns

Strategy: validation

Validate before calling

for (field, value) in [("id", &profile.id), ("name", &profile.name)] {
    if value.trim().is_empty() {
        eprintln!("profile {field} cannot be empty");
    }
}

Type guard

fn is_non_empty_token(s: &str) -> bool {
    !s.trim().is_empty()
}

Try / catch

match result {
    Err(e) if e.to_string().contains("cannot be empty") => {
        eprintln!("fill in the empty token field in the profile TOML");
    }
    other => other?,
}

Prevention

When it happens

Trigger: An agent profile TOML with an empty `id`/`name`/token field (id = "") or a value that is only whitespace, passed through load_agent_profile_identity_file or agent_profile_from_toml.

Common situations: A template profile file with placeholder left empty; a generated profile where a variable interpolation produced an empty string; deleting a value in an editor and saving.

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/f038289626fc7577. Report an issue: GitHub.

Appendix: source

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

            bail!(
                "agent profile {} may not request trust=true",
                path.display()
            );
        }
        if permissions.approval_required == Some(false) {
            bail!(
                "agent profile {} may not disable approval_required",
                path.display()
            );
        }
    }
    Ok(())
}

fn validate_agent_profile_token(path: &Path, field: &str, value: &str) -> Result<()> {
    let trimmed = value.trim();
    if trimmed.is_empty() {
        bail!("agent profile {} {field} cannot be empty", path.display());
    }
    if trimmed != value || !trimmed.chars().all(is_agent_profile_token_char) {
        bail!(
            "agent profile {} {field} must be a simple token",
            path.display()
        );
    }
    Ok(())
}

fn validate_agent_profile_model_hint(path: &Path, value: Option<&str>) -> Result<()> {
    let Some(value) = value else {
        return Ok(());
    };
    if !is_model_hint(value) {
        bail!(
            "agent profile {} model must be a visible model id without whitespace or secrets",
            path.display()

View on GitHub (pinned to 73e0f67d83)