{"record":{"id":"ba1ad6db1ce0a977","repo":"zeroclaw-labs/zeroclaw","slug":"non-success-status","errorCode":null,"errorMessage":"non-success status {}","messagePattern":"non-success status (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/zeroclaw-channels/src/discord/mod.rs","lineNumber":1520,"sourceCode":"    let url = format!(\"https://discord.com/api/v10/channels/{channel_id}\");\n    let lookup = async {\n        let resp = client\n            .get(&url)\n            .header(\"Authorization\", format!(\"Bot {bot_token}\"))\n            .send()\n            .await\n            .map_err(|e| {\n                ::zeroclaw_log::record!(\n                    ERROR,\n                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)\n                        .with_outcome(::zeroclaw_log::EventOutcome::Failure)\n                        .with_attrs(::serde_json::json!({\"error\": format!(\"{}\", e)})),\n                    \"request failed\"\n                );\n                anyhow::Error::msg(format!(\"request failed: {e}\"))\n            })?;\n        if !resp.status().is_success() {\n            anyhow::bail!(\"non-success status {}\", resp.status());\n        }\n        let body: serde_json::Value = resp.json().await.map_err(|e| {\n            ::zeroclaw_log::record!(\n                ERROR,\n                ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Fail)\n                    .with_outcome(::zeroclaw_log::EventOutcome::Failure)\n                    .with_attrs(::serde_json::json!({\"error\": format!(\"{}\", e)})),\n                \"body parse failed\"\n            );\n            anyhow::Error::msg(format!(\"body parse failed: {e}\"))\n        })?;\n        let is_thread = body\n            .get(\"type\")\n            .and_then(serde_json::Value::as_u64)\n            .map(is_thread_channel_type)\n            .unwrap_or(false);\n        Ok::<Option<String>, anyhow::Error>(if is_thread {\n            body.get(\"parent_id\")","sourceCodeStart":1502,"sourceCodeEnd":1538,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/discord/mod.rs#L1502-L1538","documentation":"Inside discord_thread_parent, a GET /channels/{channel_id} with the bot token returns non-2xx and bails with this bare status text. The caller wraps the lookup in a timeout and converts any Err — including this one — into a DEBUG log and a cached None, so thread-parent resolution silently degrades and the error never propagates outward. Common statuses: 403 Missing Permissions (bot lacks VIEW_CHANNELS), 404 (deleted channel or malformed id), 401 (bad token).","triggerScenarios":"Bot invited without View Channel on the target channel; channel deleted between message receipt and lookup; a sentinel or malformed id passed as a channel id (guaranteed non-2xx); bot token revoked mid-session.","commonSituations":"Locked/private channels where the bot receives gateway events but cannot fetch the channel object; bot removed from a guild while its threads still process; permission reorganizations by server admins.","solutions":["Grant the bot VIEW_CHANNELS on channels where thread routing matters (channel and role overrides)","Treat as non-fatal — the code already degrades to no thread parent; fixing permissions restores resolution","If 404s dominate, verify channel ids come from gateway events, not user input","If every lookup 401s, the bot token itself is invalid"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Validate the bot token once at startup so 401s are impossible mid-run:\n// GET https://discord.com/api/v10/users/@me with `Bot {token}` must return 200.\n// The lookup itself already degrades to a cached None on any error.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grant VIEW_CHANNELS on every channel the bot serves","Watch the DEBUG 'channel lookup failed' logs to catch permission drift","Take channel ids from gateway events, never user input"],"tags":["discord","permissions","channels","threads","degraded"],"backgroundTag":"discord-missing-permissions","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}