{"record":{"id":"4136641efd7cb20f","repo":"Hmbown/CodeWhale","slug":"key-label-must-contain-1-max-key-label-chars-cha","errorCode":null,"errorMessage":"key label must contain 1-{MAX_KEY_LABEL_CHARS} characters","messagePattern":"key label must contain 1-(.+?) characters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/cloud.rs","lineNumber":1149,"sourceCode":"\nfn validate_api_key(key: &str) -> Result<()> {\n    let bytes = key.len();\n    if bytes < MIN_API_KEY_BYTES || bytes as u64 > MAX_API_KEY_BYTES {\n        bail!(\"API key must be {MIN_API_KEY_BYTES}-{MAX_API_KEY_BYTES} UTF-8 bytes\");\n    }\n    if key.chars().any(is_ascii_control) {\n        bail!(\"API key contains invalid control characters\");\n    }\n    Ok(())\n}\n\nfn validate_label(label: &str) -> Result<String> {\n    let label = label.split_whitespace().collect::<Vec<_>>().join(\" \");\n    if label.is_empty()\n        || label.chars().count() > MAX_KEY_LABEL_CHARS\n        || label.chars().any(is_ascii_control)\n    {\n        bail!(\"key label must contain 1-{MAX_KEY_LABEL_CHARS} characters\");\n    }\n    Ok(label)\n}\n\nfn is_ascii_control(character: char) -> bool {\n    character <= '\\u{001f}' || character == '\\u{007f}'\n}\n\n/// Find one catalog row by id, or fail naming what the account does offer.\n///\n/// A catalog miss is the common typo, so the message lists the ids rather than\n/// leaving the user to guess or read a 404.\nfn catalog_row<'a>(catalog: &'a [CatalogProvider], provider: &str) -> Result<&'a CatalogProvider> {\n    catalog\n        .iter()\n        .find(|row| row.id == provider)\n        .ok_or_else(|| {\n            let known = catalog","sourceCodeStart":1131,"sourceCodeEnd":1167,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/cloud.rs#L1131-L1167","documentation":"validate_label enforces that a key label is non-empty, at most MAX_KEY_LABEL_CHARS characters, and free of control characters. It first collapses all whitespace runs to single spaces. The CLI bails when the normalized label violates any of these constraints.","triggerScenarios":"Calling the api-keys create/import commands with a --label that is empty after whitespace collapsing, longer than MAX_KEY_LABEL_CHARS characters, or contains control characters (crates/cli/src/cloud.rs:1149).","commonSituations":"Passing --label \"\" or --label \"   \", an overly descriptive label pasted from documentation, a label captured with terminal escape codes or newlines, or counting bytes vs multi-byte UTF-8 characters incorrectly.","solutions":["Provide a short, printable label, e.g. --label \"laptop dev\"","Trim/shorten the label so it is within MAX_KEY_LABEL_CHARS characters","Remove control characters: retype the label instead of pasting from rich text sources","Ensure the label is not purely whitespace"],"exampleFix":"// before\ncodewhale account api-keys create --label \"   \"\n// after\ncodewhale account api-keys create --label \"ci-runner-1\"","handlingStrategy":"validation","validationCode":"fn label_ok(label: &str, max_chars: usize) -> bool {\n    let normalized: String = label.split_whitespace().collect::<Vec<_>>().join(\" \");\n    !normalized.is_empty()\n        && normalized.chars().count() <= max_chars\n        && !normalized.chars().any(|c| c <= '\\u{001f}' || c == '\\u{007f}')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep labels short, printable, and single-line","Type labels directly instead of pasting from rich-text sources","Check character count (not bytes) for non-ASCII labels"],"tags":["cli","validation","label"],"backgroundTag":"invalid-argument-value","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"}