{"record":{"id":"f5decced2419dec9","repo":"jdx/mise","slug":"details","errorCode":null,"errorMessage":"{details}","messagePattern":"\\{details\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/github/oauth.rs","lineNumber":371,"sourceCode":"                debug!(\"transient error polling GitHub OAuth token: {err:#}\");\n                continue;\n            }\n        };\n\n        match response.error.as_deref() {\n            None => return Ok(response),\n            Some(\"authorization_pending\") => continue,\n            Some(\"slow_down\") => {\n                interval += 5;\n                continue;\n            }\n            Some(\"expired_token\") => bail!(\"GitHub device authorization expired\"),\n            Some(\"access_denied\") => bail!(\"GitHub device authorization was denied\"),\n            Some(error) => {\n                let details = response\n                    .error_description\n                    .unwrap_or_else(|| error.to_string());\n                bail!(\"{details}\");\n            }\n        }\n    }\n}\n\nasync fn refresh_token(cached: &CachedToken) -> Result<Option<CachedToken>> {\n    let Some(refresh_token) = cached.refresh_token.as_deref() else {\n        return Ok(None);\n    };\n    if cached\n        .refresh_expires_at\n        .is_some_and(|exp| exp <= chrono::Utc::now())\n    {\n        return Ok(None);\n    }\n\n    let settings = Settings::get();\n    let url = format!(","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/github/oauth.rs#L353-L389","documentation":"This is the fallback arm of poll_access_token's error matching: when GitHub returns any device-flow error other than authorization_pending, slow_down, expired_token, or access_denied, the code bails with the response's error_description if present, or the raw error string. GitHub's error_description is user-readable (e.g. device flow not enabled for the app, invalid client).","triggerScenarios":"token_async -> poll_access_token receives an unrecognized error field from https://github.com/login/oauth/access_token, e.g. 'incorrect_client_credentials', 'unsupported_grant_type', 'device_flow_disabled', or malformed client configuration.","commonSituations":"OAuth app client ID misconfigured or deleted; GitHub-side app setting changed (device flow disabled); proxy or API version returning an unexpected error shape; GitHub API incidents.","solutions":["Read the detailed message — it echoes GitHub's error_description for the exact cause","Verify the OAuth app's Client ID is correct and device flow is enabled in the app's developer settings","Check GitHub API status (githubstatus.com) for incidents","Retry; if persistent, re-create or fix the OAuth app configuration"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the OAuth app client id is configured and device flow is possible\nassert!(!client_id.is_empty(), \"OAuth client_id must be set before device flow\");","typeGuard":null,"tryCatchPattern":"// Surface GitHub's error_description verbatim and retry transient classes\nif let Err(e) = token {\n    tracing::error!(\"device flow failed: {e}\");\n    if is_transient(&e) { retry_with_backoff(); }\n}","preventionTips":["Keep the OAuth app's Client ID in config/versioned settings, not hardcoded","Enable device flow in the GitHub app's developer settings","Monitor GitHub status before blaming your code","Log the full error_description for diagnosis"],"tags":["oauth","github","api-error"],"backgroundTag":"oauth-token-exchange-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}