{"record":{"id":"6d28fd47ec489be0","repo":"nikivdev/code","slug":"remote-commit-message-unauthorized-run-f-auth-t","errorCode":null,"errorMessage":"remote commit message unauthorized. Run `f auth` to login.","messagePattern":"remote commit message unauthorized\\. Run `f auth` to login\\.","errorType":"exception","errorClass":null,"httpStatus":401,"severity":"error","filePath":"src/commit.rs","lineNumber":13014,"sourceCode":"    ))\n    .context(\"failed to create HTTP client for remote commit message\")?;\n\n    let payload = json!({\n        \"diff\": diff,\n        \"status\": status,\n        \"truncated\": truncated,\n    });\n\n    let response = client\n        .post(&url)\n        .bearer_auth(token)\n        .json(&payload)\n        .send()\n        .context(\"failed to request remote commit message\")?;\n\n    if !response.status().is_success() {\n        if response.status() == StatusCode::UNAUTHORIZED {\n            bail!(\"remote commit message unauthorized. Run `f auth` to login.\");\n        }\n        if response.status() == StatusCode::PAYMENT_REQUIRED {\n            bail!(\n                \"remote commit message requires an active subscription. Visit myflow to subscribe.\"\n            );\n        }\n        let status = response.status();\n        let body = response.text().unwrap_or_default();\n        bail!(\"remote commit message failed: HTTP {} {}\", status, body);\n    }\n\n    let payload: RemoteCommitMessageResponse = response\n        .json()\n        .context(\"failed to parse remote commit message response\")?;\n\n    let message = payload.message.trim().to_string();\n    if message.is_empty() {\n        bail!(\"remote commit message was empty\");","sourceCodeStart":12996,"sourceCodeEnd":13032,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L12996-L13032","documentation":"Thrown when the remote (myflow) commit-message endpoint responds with HTTP 401 Unauthorized, indicating the user's auth token is missing, expired, or invalid. The message explicitly directs the user to `f auth` to re-login.","triggerScenarios":"Calling the remote commit-message API with an expired or revoked session token, or with no token stored at all.","commonSituations":"Token expired after inactivity; user logged out on another machine invalidating the session; auth file deleted or corrupted; clock skew invalidating token validation.","solutions":["Run `f auth` to log in again and refresh the token.","Delete stale credentials and re-authenticate from scratch.","Verify the client is sending the token header correctly (check for recent auth code changes).","Check system clock if tokens are time-based and appear prematurely expired."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check for stored credentials before calling the remote endpoint\nif !auth_token_path.exists() || read_token()?.is_empty() {\n    return Err(anyhow!(\"Not logged in. Run `f auth` first.\"));\n}","typeGuard":"fn has_valid_token(token: &Option<String>) -> bool {\n    token.as_deref().map(|t| !t.is_empty()).unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"unauthorized\") => {\n        eprintln!(\"Session expired. Please run `f auth` to re-login.\");\n        prompt_reauth()?;\n    }\n    other => other,\n}","preventionTips":["Re-run `f auth` periodically; tokens expire.","Handle 401 centrally by triggering automatic re-login.","Don't delete or hand-edit the credential store file.","Detect token expiry client-side and refresh before requests."],"tags":["authentication","http-401","remote-api"],"backgroundTag":"auth-token-expired","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}