Hmbown/CodeWhale · error · anyhow::Error

The Codewhale service returned an account without an ID

Error message

The Codewhale service returned an account without an ID

What it means

The `me` command fetches /api/me and validates the returned account has a non-empty id before caching it. If the service responds 200 with a user object whose id is blank or whitespace, this error is thrown because the account cannot be identified or reconciled with stored state.

Solutions

  1. Retry the request; if persistent, contact the Codewhale service operator — the account record is broken server-side.
  2. Verify you are pointed at the correct API origin (not a stub/mock).
  3. Log out and log in again to force a fresh session against the real service.
Defensive patterns

Strategy: retry

Try / catch

// Rust
match cloud.me() {
    Err(e) if e.to_string().contains("account without an ID") => {
        // server-side data problem; retry, then contact the service operator
    }
    other => other,
}

Prevention

When it happens

Trigger: GET /api/me returning 200 with a MeResponse whose user.id is empty or whitespace-only — a server-side data problem, not a client input problem.

Common situations: Service bug or partially provisioned account; a proxy serving a mocked/stub response; pointing at a dev origin with incomplete user records.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

    fn load_auth(&self) -> Result<Option<StoredCloudAuth>> {
        self.account_store.load().context(
            "the local Codewhale account session is unreadable; run `codewhale account logout` and sign in again",
        )
    }

    fn save_auth(&self, bundle: AuthBundle) -> Result<()> {
        self.account_store
            .save(bundle)
            .context("failed to save the Codewhale account session in the local secret store")
    }

    fn me(&self) -> Result<CloudUser> {
        let (response, snapshot) =
            self.execute_authenticated_snapshot(HttpMethod::Get, "/api/me", None)?;
        let me: MeResponse = expect_json(response, &[200])?;
        if me.user.id.trim().is_empty() {
            bail!("The Codewhale service returned an account without an ID");
        }
        if let Some(mut stored) = snapshot.load()? {
            if stored
                .bundle
                .user
                .as_ref()
                .is_some_and(|user| !user.id.is_empty() && user.id != me.user.id)
            {
                bail!("The signed-in account changed. Refresh and try again.");
            }
            stored.bundle.user = Some(me.user.clone());
            if self
                .account_store
                .save_if_unchanged(&snapshot, stored.bundle)?
                .is_none()
            {
                bail!("The signed-in account changed. Refresh and try again.");
            }

View on GitHub (pinned to 73e0f67d83)