{"record":{"id":"0676ce2bf1967134","repo":"Hmbown/CodeWhale","slug":"agent-profile-field-must-be-a-simple-token","errorCode":null,"errorMessage":"agent profile {} {field} must be a simple token","messagePattern":"agent profile (.+?) (.+?) must be a simple token","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/profile.rs","lineNumber":469,"sourceCode":"            );\n        }\n        if permissions.approval_required == Some(false) {\n            bail!(\n                \"agent profile {} may not disable approval_required\",\n                path.display()\n            );\n        }\n    }\n    Ok(())\n}\n\nfn validate_agent_profile_token(path: &Path, field: &str, value: &str) -> Result<()> {\n    let trimmed = value.trim();\n    if trimmed.is_empty() {\n        bail!(\"agent profile {} {field} cannot be empty\", path.display());\n    }\n    if trimmed != value || !trimmed.chars().all(is_agent_profile_token_char) {\n        bail!(\n            \"agent profile {} {field} must be a simple token\",\n            path.display()\n        );\n    }\n    Ok(())\n}\n\nfn validate_agent_profile_model_hint(path: &Path, value: Option<&str>) -> Result<()> {\n    let Some(value) = value else {\n        return Ok(());\n    };\n    if !is_model_hint(value) {\n        bail!(\n            \"agent profile {} model must be a visible model id without whitespace or secrets\",\n            path.display()\n        );\n    }\n    Ok(())","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/fleet/profile.rs#L451-L487","documentation":"validate_agent_profile_token requires id/name and base_role/role_hint to be simple tokens: non-empty, no leading/trailing whitespace, and only ASCII alphanumerics plus '-', '_' and '.' (is_agent_profile_token_char). Anything else - spaces, slashes, colons, unicode - is rejected because these values become roster keys and role identifiers.","triggerScenarios":"id = \"code reviewer\" (inner space), base_role = \"fleet/oracle\", name = \"codewhale agent\" feeding the id, or a filename stem fallback like \"my agent\" from my agent.toml. The test suite reproduces it with id = \"bad id\".","commonSituations":"Putting a friendly multi-word label in name (which feeds the id) instead of display_name; role names copied with slashes or colons; profile files whose names contain spaces.","solutions":["Change id/name/base_role to a slug: lowercase letters, digits, '-', '_', '.' only (e.g. \"code-reviewer\")","Move human-readable prose to display_name or description - those fields accept free text","Rename profile files whose stem contains spaces, since the stem becomes the id when id/name are absent"],"exampleFix":"# before\nname = \"code reviewer\"\n\n# after\nid = \"code-reviewer\"\ndisplay_name = \"Code Reviewer\"","handlingStrategy":"validation","validationCode":"const fn is_agent_profile_token_char(c: char) -> bool {\n    c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.')\n}\n\nfn profile_fields_are_tokens(fields: &[&str]) -> bool {\n    fields.iter().all(|v| {\n        let t = v.trim();\n        !t.is_empty() && t == *v && v.chars().all(is_agent_profile_token_char)\n    })\n}","typeGuard":"fn is_profile_token(s: &str) -> bool {\n    let t = s.trim();\n    !t.is_empty() && t == s\n        && t.chars().all(|c| c.is_ascii_alphanumeric() || matches!(c, '-' | '_' | '.'))\n}","tryCatchPattern":"match load_agent_profile_file(&path) {\n    Ok(p) => Ok(p),\n    Err(err) if err.to_string().contains(\"must be a simple token\") => {\n        Err(anyhow!(\"profile {path:?}: use [A-Za-z0-9._-] slugs for id/name/base_role; put prose in display_name\"))\n    }\n    Err(err) => Err(err),\n}","preventionTips":["Keep id/name/base_role as kebab-case slugs; reserve spaces and punctuation for display_name/description","Name profile files without spaces since the stem becomes the id","Slugify any human input before writing it into identity fields"],"tags":["agent-profile","toml","validation","identifier","fleet"],"backgroundTag":"invalid-identifier-format","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}