{"record":{"id":"0a5b3b1609e48947","repo":"Hmbown/CodeWhale","slug":"not-signed-in-run-codewhale-account-login-first","errorCode":null,"errorMessage":"Not signed in. Run `codewhale account login` first","messagePattern":"Not signed in\\. Run `codewhale account login` first","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/cli/src/cloud.rs","lineNumber":446,"sourceCode":"            .execute(CloudRequest {\n                method: HttpMethod::Post,\n                path: \"/api/auth/logout\".to_string(),\n                bearer: None,\n                body: Some(body),\n            })\n            .is_ok_and(|response| (200..300).contains(&response.status));\n        self.clear_auth()?;\n        Ok(remote_revoked)\n    }\n\n    fn execute_authenticated(\n        &self,\n        method: HttpMethod,\n        path: &str,\n        body: Option<Vec<u8>>,\n    ) -> Result<CloudResponse> {\n        let Some(mut stored) = self.load_auth()? else {\n            bail!(\"Not signed in. Run `codewhale account login` first\");\n        };\n        let first = self.transport.execute(CloudRequest {\n            method,\n            path: path.to_string(),\n            bearer: Some(stored.bundle.access_token.clone()),\n            body: body.clone(),\n        })?;\n        if first.status != 401 {\n            return Ok(first);\n        }\n\n        let refresh = self.transport.execute(CloudRequest {\n            method: HttpMethod::Post,\n            path: \"/api/auth/refresh\".to_string(),\n            bearer: None,\n            body: Some(json_body(&RefreshRequest {\n                refresh_token: &stored.bundle.refresh_token,\n            })?),","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/cli/src/cloud.rs#L428-L464","documentation":"execute_authenticated is the gate for all authenticated cloud calls: it loads the stored session from the OS credential store, and when none exists it bails with this sign-in required message before any HTTP request is made. It is purely local state — no network round trip happened.","triggerScenarios":"Running `codewhale account keys set`, `account me`, `account logout`, push/pull, or any command routed through execute_authenticated before ever completing `codewhale account login`; or after logout/remote revocation cleared the stored bundle.","commonSituations":"Fresh machine/container with no session, session cleared by `account logout` or by a 401-triggered clear_auth from errors 28/29, keyring entry deleted manually, or a different --profile than the one logged in.","solutions":["Run `codewhale account login` and complete the device flow.","If you logged in before, check you are using the same --profile the session was stored under.","Confirm the OS credential manager is unlocked (Keychain/Secret Service) so the stored session can be read.","If login previously failed mid-way, rerun it — the bundle is only stored on success."],"exampleFix":"# before\ncodewhale account keys set anthropic\n\n# after\ncodewhale account login && codewhale account keys set anthropic","handlingStrategy":"validation","validationCode":"// Check for a session before dispatching account commands\nif account_store.load()?.is_none() {\n    eprintln!(\"Not signed in — starting login\");\n    run_login(profile).await?;\n}","typeGuard":null,"tryCatchPattern":"match client.execute_authenticated(method, path, body).await {\n    Ok(resp) => resp,\n    Err(e) if e.to_string().contains(\"Not signed in\") => {\n        run_login(profile).await?;               // then retry the original call once\n        client.execute_authenticated(method, path, body).await\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Gate account subcommands on a cheap load_auth() check in wrappers.","Use a consistent --profile so sessions are found where they were stored.","After logout or 401-clears, proactively re-login before the next batch job."],"tags":["authentication","cloud","cli","missing-credentials"],"backgroundTag":"not-authenticated","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}