{"record":{"id":"223da063d118cafc","repo":"zeroclaw-labs/zeroclaw","slug":"gateway-registration-failed-status-err","errorCode":null,"errorMessage":"gateway registration failed ({status}): {err}","messagePattern":"gateway registration failed \\((.+?)\\): (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-channels/src/dingtalk.rs","lineNumber":130,"sourceCode":"            \"subscriptions\": [\n                {\n                    \"type\": \"CALLBACK\",\n                    \"topic\": DINGTALK_BOT_CALLBACK_TOPIC,\n                }\n            ],\n        });\n\n        let resp = self\n            .http_client()\n            .post(\"https://api.dingtalk.com/v1.0/gateway/connections/open\")\n            .json(&body)\n            .send()\n            .await?;\n\n        if !resp.status().is_success() {\n            let status = resp.status();\n            let err = resp.text().await.unwrap_or_default();\n            anyhow::bail!(\"gateway registration failed ({status}): {err}\");\n        }\n\n        let gw: GatewayResponse = resp.json().await?;\n        Ok(gw)\n    }\n}\n\nimpl ::zeroclaw_api::attribution::Attributable for DingTalkChannel {\n    fn role(&self) -> ::zeroclaw_api::attribution::Role {\n        ::zeroclaw_api::attribution::Role::Channel(\n            ::zeroclaw_api::attribution::ChannelKind::DingTalk,\n        )\n    }\n    fn alias(&self) -> &str {\n        &self.alias\n    }\n}\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/dingtalk.rs#L112-L148","documentation":"DingTalkChannel's register_connection POSTs clientId/clientSecret plus a CALLBACK subscription for /v1.0/im/bot/messages/get to https://api.dingtalk.com/v1.0/gateway/connections/open (Stream Mode). Any non-2xx becomes this error with the status and body. Both listen() startup and health_check() route through it, so credential or endpoint problems surface here first, before any WebSocket is opened.","triggerScenarios":"Invalid or rotated clientSecret; clientId of an app whose bot capability is not enabled; region mismatch — the code hardcodes api.dingtalk.com while EU apps must use api.dingtalk.eu; server IP not on the app allowlist; app not published/approved so Stream Mode is refused; per-channel proxy (build_channel_proxy_client) mangling the POST.","commonSituations":"Secret regenerated in the DingTalk developer console while config still holds the old one; EU-hosted app against the international host; corporate proxy blocking api.dingtalk.com; sandbox apps without stream permission.","solutions":["Decode the status/body in the message — DingTalk returns a specific errorCode/message (e.g. invalid clientSecret)","Re-copy Client ID and Client Secret from the DingTalk Open Platform app into [channels.dingtalk.<alias>]","Confirm the app has the bot/message-receive capability and Stream Mode enabled","For EU apps the endpoint must be api.dingtalk.eu — currently hardcoded, so use an international app or patch the URL","Remove or verify proxy_url if a proxy intercepts the registration POST"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// register_connection is what health_check exercises:\nif !dingtalk_channel.health_check().await {\n    // gateway registration failed — fix client_id/client_secret/region before listen()\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = channel.listen(tx).await {\n    if e.to_string().contains(\"gateway registration failed\") {\n        // credential/endpoint problem: reconnect loops will keep failing until config is fixed\n    }\n}","preventionTips":["Call health_check at startup and skip reconnect loops while it fails","Rotate the DingTalk secret in config the moment you rotate it in the console","Pin the app region and the API host together — EU apps need api.dingtalk.eu"],"tags":["dingtalk","websocket","stream-mode","auth","config"],"backgroundTag":"dingtalk-gateway-registration-failed","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}