{"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":528,"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":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/profile.rs#L510-L546","documentation":"Token fields in agent profiles must be simple tokens: no surrounding whitespace and every character must satisfy is_agent_profile_token_char. A value that trims differently than itself or contains disallowed characters (spaces, punctuation, unicode) is rejected.","triggerScenarios":"An agent profile field such as id = \"my agent\" (space inside), id = \" researcher\" (leading space), or containing characters like '/' or ':' passed through validate_agent_profile_token from load_agent_profile_identity_file or agent_profile_from_toml.","commonSituations":"Human-readable display names put into id fields ('My Research Agent!'); pasted values carrying leading/trailing whitespace; ids copied from paths or model strings containing slashes.","solutions":["Rewrite the value using only simple token characters (letters, digits, hyphens/underscores — see is_agent_profile_token_char)","Remove leading/trailing whitespace from the field","Move any descriptive text into a comment or a display-name field that is not token-validated"],"exampleFix":"// before\nid = \"My Research Agent\"\n\n// after\nid = \"my-research-agent\"","handlingStrategy":"validation","validationCode":"fn is_simple_token(s: &str) -> bool {\n    let t = s.trim();\n    t == s && !t.is_empty() && t.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')\n}\nif !is_simple_token(&profile.id) { eprintln!(\"id must be a simple token\"); }","typeGuard":"fn is_simple_token(s: &str) -> bool {\n    let t = s.trim();\n    t == s && !t.is_empty() && t.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"must be a simple token\") => {\n        eprintln!(\"rewrite the field using only letters, digits, hyphens, underscores\");\n    }\n    other => other?,\n}","preventionTips":["Use kebab-case ids without spaces or punctuation in profiles","Strip whitespace from values before writing generated profiles","Keep human-readable descriptions out of token-validated fields"],"tags":["fleet","agent-profiles","validation","identifier-format"],"backgroundTag":"invalid-identifier-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}