{"record":{"id":"f4319f05727b3b9f","repo":"nikivdev/code","slug":"hub-returned-error","errorCode":null,"errorMessage":"hub returned error: {}","messagePattern":"hub returned error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/commit.rs","lineNumber":15324,"sourceCode":"        .post(&url)\n        .json(&payload)\n        .send()\n        .context(\"failed to submit commit to hub\")?;\n\n    if resp.status().is_success() {\n        // Parse response to get task_id\n        let body: serde_json::Value = resp.json().unwrap_or_default();\n        if let Some(task_id) = body.get(\"task_id\").and_then(|v| v.as_str()) {\n            println!(\"Delegated commit to hub\");\n            println!(\"  View logs: f logs --task-id {}\", task_id);\n            println!(\"  Stream logs: f logs --task-id {} --follow\", task_id);\n        } else {\n            println!(\"Delegated commit to hub\");\n        }\n        Ok(())\n    } else {\n        let body = resp.text().unwrap_or_default();\n        bail!(\"hub returned error: {}\", body);\n    }\n}\n\nfn delegate_to_hub_with_check(\n    command_name: &str,\n    push: bool,\n    include_context: bool,\n    review_selection: ReviewSelection,\n    author_message: Option<&str>,\n    max_tokens: usize,\n    queue: CommitQueueMode,\n    include_unhash: bool,\n    stage_paths: &[String],\n    gate_overrides: CommitGateOverrides,\n) -> Result<()> {\n    let repo_root = resolve_commit_with_check_root()?;\n    warn_if_commit_invoked_from_subdir(&repo_root);\n","sourceCodeStart":15306,"sourceCodeEnd":15342,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/commit.rs#L15306-L15342","documentation":"Thrown when the HTTP response from the hub's commit-delegation endpoint has a non-success status. The error message contains the raw response body, which is the hub's error payload. It indicates the delegation request reached the hub but the hub rejected or failed the operation.","triggerScenarios":"Calling the hub commit-delegation flow and receiving a 4xx/5xx response; the branch prints the body via `bail!(\"hub returned error: {}\", body)`.","commonSituations":"Hub server not running or returning 500, auth token expired (401), hub rejects the payload due to schema/validation errors (400/422), or a proxy/gateway returns an HTML error page.","solutions":["Inspect the embedded body — it names the hub-side cause (401/404/500 etc.)","Confirm the hub service is running and reachable at the configured URL","Refresh hub credentials/token if the status was 401/403","Compare the request payload against the hub API schema if the status was 400/422"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight the hub before delegating\nlet health = reqwest::blocking::get(format!(\"{hub_url}/health\"))?\n    .status();\nif !health.is_success() {\n    eprintln!(\"hub unhealthy: {health}\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match delegate_commit_to_hub(&payload) {\n    Err(e) if e.to_string().starts_with(\"hub returned error\") => {\n        eprintln!(\"Hub rejected the commit: {e}\");\n        eprintln!(\"Check hub is running, your token is valid, and payload schema matches.\");\n    }\n    other => other?,\n}","preventionTips":["Retry with backoff on 5xx before surfacing the error","Refresh hub auth tokens proactively","Version-check the hub API before delegating new commands","Log the hub URL and status alongside the body for faster triage"],"tags":["network","http","hub","api"],"backgroundTag":"http-error-response","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}