Hmbown/CodeWhale · error
key label must contain 1
Error message
key label must contain 1-{MAX_KEY_LABEL_CHARS} characters What it means
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.
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
Example fix
// before codewhale account api-keys create --label " " // after codewhale account api-keys create --label "ci-runner-1"
Defensive patterns
Strategy: validation
Validate before calling
fn label_ok(label: &str, max_chars: usize) -> bool {
let normalized: String = label.split_whitespace().collect::<Vec<_>>().join(" ");
!normalized.is_empty()
&& normalized.chars().count() <= max_chars
&& !normalized.chars().any(|c| c <= '\u{001f}' || c == '\u{007f}')
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- A positive pull request number is required
- API key contains invalid control characters
- API key id must be lowercase hex characters — the part…
- API key input is unexpectedly large
- API key must be - UTF-8 bytes
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/4136641efd7cb20f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/cloud.rs:1149
fn validate_api_key(key: &str) -> Result<()> {
let bytes = key.len();
if bytes < MIN_API_KEY_BYTES || bytes as u64 > MAX_API_KEY_BYTES {
bail!("API key must be {MIN_API_KEY_BYTES}-{MAX_API_KEY_BYTES} UTF-8 bytes");
}
if key.chars().any(is_ascii_control) {
bail!("API key contains invalid control characters");
}
Ok(())
}
fn validate_label(label: &str) -> Result<String> {
let label = label.split_whitespace().collect::<Vec<_>>().join(" ");
if label.is_empty()
|| label.chars().count() > MAX_KEY_LABEL_CHARS
|| label.chars().any(is_ascii_control)
{
bail!("key label must contain 1-{MAX_KEY_LABEL_CHARS} characters");
}
Ok(label)
}
fn is_ascii_control(character: char) -> bool {
character <= '\u{001f}' || character == '\u{007f}'
}
/// Find one catalog row by id, or fail naming what the account does offer.
///
/// A catalog miss is the common typo, so the message lists the ids rather than
/// leaving the user to guess or read a 404.
fn catalog_row<'a>(catalog: &'a [CatalogProvider], provider: &str) -> Result<&'a CatalogProvider> {
catalog
.iter()
.find(|row| row.id == provider)
.ok_or_else(|| {
let known = catalogView on GitHub (pinned to 73e0f67d83)