{"record":{"id":"92520c54fec219e8","repo":"zeroclaw-labs/zeroclaw","slug":"ms365-device-code-request-failed-status","errorCode":null,"errorMessage":"ms365: device code request failed ({status})","messagePattern":"ms365: device code request failed \\((.+?)\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-tools/src/microsoft365/auth.rs","lineNumber":215,"sourceCode":"            .post(&device_code_url)\n            .form(&[\n                (\"client_id\", self.config.client_id.as_str()),\n                (\"scope\", &scope),\n            ])\n            .send()\n            .await\n            .context(\"ms365: failed to request device code\")?;\n\n        if !resp.status().is_success() {\n            let status = resp.status();\n            let body = resp.text().await.unwrap_or_default();\n            ::zeroclaw_log::record!(\n                DEBUG,\n                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)\n                    .with_attrs(::serde_json::json!({\"body\": body})),\n                \"ms365: device_code initiation raw error\"\n            );\n            anyhow::bail!(\"ms365: device code request failed ({status})\");\n        }\n\n        let device_resp: DeviceCodeResponse = resp\n            .json()\n            .await\n            .context(\"ms365: failed to parse device code response\")?;\n\n        // Log only a generic prompt; the full device_resp.message may contain\n        // sensitive verification URIs or codes that should not appear in logs.\n        ::zeroclaw_log::record!(\n            INFO,\n            ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note),\n            \"ms365: device code auth required — follow the instructions shown to the user\"\n        );\n        // Print the user-facing message to stderr so the operator can act on it\n        // without it being captured in structured log sinks.\n        eprintln!(\"ms365: {}\", device_resp.message);\n","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-tools/src/microsoft365/auth.rs#L197-L233","documentation":"Error \"ms365: device code request failed ({status})\" thrown in zeroclaw-labs/zeroclaw.","triggerScenarios":"Thrown at crates/zeroclaw-tools/src/microsoft365/auth.rs:215 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the MS365 client ID and tenant; check the device code endpoint status."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}