Hmbown/CodeWhale · error · anyhow::Error
The signed-in account changed. Refresh and try again.
Error message
The signed-in account changed. Refresh and try again.
What it means
While refreshing the user via /api/me, the client compares the service's account id against the id stored in the local account bundle. If a different non-empty id is already stored, it refuses to overwrite and throws this optimistic-concurrency error.
Solutions
- Log out (`codewhale logout`) and log in again as the intended account.
- Check other open sessions/terminals that may have switched accounts concurrently.
- Re-run the command once you are signed in as the account you expect.
Defensive patterns
Strategy: try-catch
Try / catch
// Rust
match cloud.me() {
Err(e) if e.to_string().contains("signed-in account changed") => {
// re-authenticate: logout, login, then retry
}
other => other,
} Prevention
- Avoid signing into different accounts from multiple concurrent sessions on one machine.
- After switching accounts, re-run the command instead of reusing stale state.
When it happens
Trigger: Running `codewhale me` (or any command via execute_authenticated) when the locally stored signed-in account belongs to a different user than the service returns — typically after switching accounts or tokens in another session/process.
Common situations: Two terminal sessions signed in as different accounts; a shared machine where another user re-logged-in; stale token refreshed against a different account.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Cloud agents are not available for this account yet; cloud…
- Cloud agents are not available for this account yet; cloud…
- cloud dispatch fails closed: the cloud agent runs Codewhale…
- Not signed in. Run `codewhale login` first
- The Codewhale service returned HTTP
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/1b81b675cf34342f.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/cloud.rs:431
.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.");
}
}
Ok(me.user)
}
fn set_key(&self, provider: &str, key: &str, label: &str) -> Result<()> {
let path = format!("/api/model-keys/{provider}");
let response = self.execute_authenticated(
HttpMethod::Put,
&path,View on GitHub (pinned to 73e0f67d83)