nikivdev/code · error
hub returned error: {}
Error message
hub returned error: {} What it means
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.
Source
Thrown at src/commit.rs:15324
.post(&url)
.json(&payload)
.send()
.context("failed to submit commit to hub")?;
if resp.status().is_success() {
// Parse response to get task_id
let body: serde_json::Value = resp.json().unwrap_or_default();
if let Some(task_id) = body.get("task_id").and_then(|v| v.as_str()) {
println!("Delegated commit to hub");
println!(" View logs: f logs --task-id {}", task_id);
println!(" Stream logs: f logs --task-id {} --follow", task_id);
} else {
println!("Delegated commit to hub");
}
Ok(())
} else {
let body = resp.text().unwrap_or_default();
bail!("hub returned error: {}", body);
}
}
fn delegate_to_hub_with_check(
command_name: &str,
push: bool,
include_context: bool,
review_selection: ReviewSelection,
author_message: Option<&str>,
max_tokens: usize,
queue: CommitQueueMode,
include_unhash: bool,
stage_paths: &[String],
gate_overrides: CommitGateOverrides,
) -> Result<()> {
let repo_root = resolve_commit_with_check_root()?;
warn_if_commit_invoked_from_subdir(&repo_root);
View on GitHub (pinned to a747e741ae)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight the hub before delegating
let health = reqwest::blocking::get(format!("{hub_url}/health"))?
.status();
if !health.is_success() {
eprintln!("hub unhealthy: {health}");
return Ok(());
} Try / catch
match delegate_commit_to_hub(&payload) {
Err(e) if e.to_string().starts_with("hub returned error") => {
eprintln!("Hub rejected the commit: {e}");
eprintln!("Check hub is running, your token is valid, and payload schema matches.");
}
other => other?,
} Prevention
- 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
When it happens
Trigger: Calling the hub commit-delegation flow and receiving a 4xx/5xx response; the branch prints the body via `bail!("hub returned error: {}", body)`.
Common situations: 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.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Maple MCP request failed ({}): {}
- API error {}: {}
- LM Studio returned status {}: {}
- gitedit publish failed: HTTP {}
- Gemini API error {}: {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/f4319f05727b3b9f.
Report an issue: GitHub.