{"record":{"id":"45bb881ea0850615","repo":"zeroclaw-labs/zeroclaw","slug":"gateway-responded-status-err","errorCode":null,"errorMessage":"Gateway responded {status}: {err}","messagePattern":"Gateway responded (.+?): (.+?)","errorType":"http","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/main.rs","lineNumber":6879,"sourceCode":"    let prefix = config.gateway.path_prefix.as_deref();\n    let client = reqwest::Client::new();\n    match cmd {\n        SopCommands::Pending => {\n            let url = gateway_admin_url(&host, port, prefix, \"/admin/sop/pending\");\n            let resp = client\n                .get(&url)\n                .timeout(std::time::Duration::from_secs(5))\n                .send()\n                .await\n                .map_err(|e| anyhow::Error::msg(format!(\"Failed to connect to gateway: {e}\")))?;\n            let status = resp.status();\n            let body: serde_json::Value = resp.json().await.unwrap_or_default();\n            if !status.is_success() {\n                let err = body\n                    .get(\"error\")\n                    .and_then(|v| v.as_str())\n                    .unwrap_or(\"request failed\");\n                anyhow::bail!(\"Gateway responded {status}: {err}\");\n            }\n            let pending = body\n                .get(\"pending\")\n                .and_then(|p| p.as_array())\n                .cloned()\n                .unwrap_or_default();\n            if pending.is_empty() {\n                println!(\n                    \"{}\",\n                    t(\"cli-sop-pending-none\", \"No SOP runs waiting for approval.\")\n                );\n            } else {\n                println!(\n                    \"{}\",\n                    t(\"cli-sop-pending-header\", \"SOP runs waiting for approval:\")\n                );\n                for r in pending {\n                    let run_id = r.get(\"run_id\").and_then(|v| v.as_str()).unwrap_or(\"?\");","sourceCodeStart":6861,"sourceCodeEnd":6897,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/src/main.rs#L6861-L6897","documentation":"The CLI reached the gateway but `GET /admin/sop/pending` returned a non-2xx status; the message embeds the HTTP status code plus the gateway's `error` string from the JSON body (or 'request failed' when the body carries none). Connection-level failures raise a separate 'Failed to connect to gateway' error.","triggerScenarios":"`zeroclaw sop pending` when the gateway returns 401/403 (admin authentication), 404 (`[gateway]` path_prefix mismatch or a daemon older than the SOP admin routes), or 5xx (daemon-side failure).","commonSituations":"The `[gateway]` block pointing at the wrong port or service; a path_prefix configured on the daemon but not the CLI (or vice versa); an admin credential expired or never provisioned; running a pre-SOP daemon version.","solutions":["Confirm the service on `[gateway]` host/port is the ZeroClaw daemon and is healthy (gateway logs / status output)","Align `[gateway]` host, port, and path_prefix in the CLI config with the daemon's actual settings","Re-provision or fix the admin credential if the status is 401/403","Upgrade the daemon if it predates the `/admin/sop/*` routes (404 with a correct prefix)"],"exampleFix":"# before: daemon serves under a prefix, CLI config has none\n[gateway]\nhost = \"127.0.0.1\"\nport = 8080\n# after\n[gateway]\nhost = \"127.0.0.1\"\nport = 8080\npath_prefix = \"/zeroclaw\"","handlingStrategy":"try-catch","validationCode":"# preflight: daemon reachable and admin routes present\ncurl -fsS \"http://${ZC_GW_HOST}:${ZC_GW_PORT}${ZC_GW_PREFIX}/admin/sop/pending\" >/dev/null \\\n  || echo \"gateway preflight failed\" >&2","typeGuard":null,"tryCatchPattern":"if ! out=\"$(zeroclaw sop pending 2>&1)\"; then\n  case \"$out\" in\n    *\"Failed to connect\"*) echo \"daemon unreachable\"; exit 2 ;;                 # transport\n    *\"Gateway responded 5\"*) retry_with_backoff zeroclaw sop pending ;;          # server-side\n    *\"Gateway responded 4\"*) echo \"$out\"; exit 1 ;;                             # config/auth: do not retry\n  esac\nfi","preventionTips":["Share one `[gateway]` config source between CLI and daemon so host/port/prefix cannot drift","Monitor daemon health before running SOP operations","Alert on 4xx from admin endpoints as config drift, not transient failure"],"tags":["gateway","http","sop","daemon","zeroclaw"],"backgroundTag":"http-error-response","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}