googleworkspace/cli · error · GwsError

5

5

Error message

HTTP request failed: {e}

What it means

Transport-level failure inside `get_json()`, the shared GET helper used by every workflow helper (`+standup-report`, `+focus`, etc.). The reqwest `send()` itself errored — DNS failure, connection refused/reset, TLS problem, or an invalid proxy — before any HTTP status existed. Distinct from the sibling branch which turns non-2xx statuses into `GwsError::Api` with reason `workflow_request_failed`.

Source

Thrown at crates/google-workspace-cli/src/helpers/workflows.rs:244

}

// ---------------------------------------------------------------------------
// Handlers
// ---------------------------------------------------------------------------

async fn get_json(
    client: &reqwest::Client,
    url: &str,
    token: &str,
    query: &[(&str, &str)],
) -> Result<Value, GwsError> {
    let resp = client
        .get(url)
        .query(query)
        .bearer_auth(token)
        .send()
        .await
        .map_err(|e| GwsError::Other(anyhow::anyhow!("HTTP request failed: {e}")))?;

    if !resp.status().is_success() {
        let status = resp.status();
        let body = resp.text().await.unwrap_or_default();
        return Err(GwsError::Api {
            code: status.as_u16(),
            message: body,
            reason: "workflow_request_failed".to_string(),
            enable_url: None,
        });
    }

    resp.json::<Value>()
        .await
        .map_err(|e| GwsError::Other(anyhow::anyhow!("JSON parse failed: {e}")))
}

fn format_and_print(value: &Value, matches: &ArgMatches) {

View on GitHub (pinned to a3768d0e82)

Solutions

  1. Verify egress: `curl -sS -o /dev/null -w '%{http_code}' https://www.googleapis.com/` should print an HTTP code.
  2. Fix or unset broken proxy env vars (HTTPS_PROXY, ALL_PROXY) in the shell/session running gws.
  3. Retry — this path has no automatic retry, and transient resets are common on flaky links.
  4. On locked-down CI, allowlist *.googleapis.com (and accounts.google.com) in the egress firewall.
Defensive patterns

Strategy: retry

Try / catch

// wrap workflow helper invocations with bounded retry on transport errors
for attempt in 1..=3 {
    match run_workflow(&args).await {
        Err(GwsError::Other(e)) if e.to_string().contains("HTTP request failed") && attempt < 3 => {
            tokio::time::sleep(std::time::Duration::from_secs(2u64.pow(attempt))).await;
        }
        other => return other,
    }
}

Prevention

When it happens

Trigger: Running `gws calendar +standup-report` (or any workflow helper) with no internet; DNS for `www.googleapis.com`/`tasks.googleapis.com` failing; HTTPS_PROXY pointing at a dead proxy; a firewall silently resetting connections to Google endpoints.

Common situations: CI runners with restricted egress; laptops in airplane mode; corporate networks requiring a proxy that is not exported into the shell running gws.

Related errors


AI-assisted analysis of googleworkspace/cli@a3768d0e82 (2026-08-16). Data as JSON: /api/errors/c28c2b980f6b1939. Report an issue: GitHub.