Hmbown/CodeWhale · error · anyhow::Error

` ` is not a valid provider id. Ids are 1-64 characters of…

Error message

`{}` is not a valid provider id. Ids are 1-64 characters of lowercase letters, digits, and `-`. Run `codewhale account keys list` to see the account's providers

What it means

validate_provider_id checks that a cloud provider id is 1-64 characters of lowercase letters, digits, and hyphens before it can be safely embedded in a URL path. Any other identifier format is rejected with this message listing the account's providers via `codewhale account keys list`.

Solutions

  1. Run `codewhale account keys list` and copy the exact provider id.
  2. Trim whitespace and replace underscores/spaces with hyphens; lowercase the value.
  3. If the provider id comes from config, fix the config value to match the validated format.

Example fix

// before
codewhale cloud run_with "My_Provider"
// after
codewhale cloud run_with "my-provider"
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_provider_id(id: &str) -> bool {
    let b = id.as_bytes();
    (1..=64).contains(&b.len())
        && b.iter().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || *c == b'-')
}

Prevention

When it happens

Trigger: Passing an invalid provider string to `codewhale` cloud subcommands that take a provider argument (e.g. run_with, key management) — empty string, uppercase, spaces, underscore, slashes (path traversal), or over 64 characters.

Common situations: Typo or hand-copied provider id with whitespace; using a display name instead of the id; shell variable containing a URL or path; old scripts written before id normalization.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/670ca13429bbf28f. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/cloud.rs:201

            .or_else(|| ProviderKind::parse_config_identity(&self.id))
    }
}

/// Accept a provider id conservatively before it is ever put in a URL path.
///
/// `^[a-z0-9][a-z0-9-]{0,63}$`. The catalog is remote data, so this guards
/// both directions: a hostile catalog cannot smuggle a path segment, and a
/// mistyped argument fails locally instead of as a confusing 404.
fn validate_provider_id(value: &str) -> Result<String> {
    let trimmed = value.trim();
    let bytes = trimmed.as_bytes();
    let well_formed = (1..=64).contains(&bytes.len())
        && (bytes[0].is_ascii_lowercase() || bytes[0].is_ascii_digit())
        && bytes
            .iter()
            .all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || *byte == b'-');
    if !well_formed {
        bail!(
            "`{}` is not a valid provider id. Ids are 1-64 characters of lowercase letters, digits, and `-`. Run `codewhale account keys list` to see the account's providers",
            printable(trimmed)
        );
    }
    Ok(trimmed.to_string())
}

#[derive(Clone, Copy, PartialEq, Eq)]
enum HttpMethod {
    Get,
    Post,
    Put,
    Delete,
}

pub(crate) struct CloudRequest {
    method: HttpMethod,
    path: String,

View on GitHub (pinned to 73e0f67d83)