googleworkspace/cli · error · GwsError
Failed to fetch sendAs settings: {e}
Error message
Failed to fetch sendAs settings: {e} What it means
Transport-level failure in `fetch_send_as_identities` (used when composing mail to resolve which identity the From address maps to): `send_with_retry` could not complete `GET https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs` after its retry budget. Non-2xx statuses take the `build_api_error` path, so this specifically means the request never got an HTTP response (or exhausted retries).
Source
Thrown at crates/google-workspace-cli/src/helpers/gmail/mod.rs:461
#[derive(Debug)]
struct SendAsIdentity {
mailbox: Mailbox,
is_default: bool,
}
/// Fetch all send-as identities from the Gmail settings API.
async fn fetch_send_as_identities(
client: &reqwest::Client,
token: &str,
) -> Result<Vec<SendAsIdentity>, GwsError> {
let resp = crate::client::send_with_retry(|| {
client
.get("https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs")
.bearer_auth(token)
})
.await
.map_err(|e| GwsError::Other(anyhow::anyhow!("Failed to fetch sendAs settings: {e}")))?;
if !resp.status().is_success() {
let status = resp.status().as_u16();
let body = resp
.text()
.await
.unwrap_or_else(|_| "(error body unreadable)".to_string());
return Err(build_api_error(
status,
&body,
"Failed to fetch sendAs settings",
));
}
let body: Value = resp
.json()
.await
.map_err(|e| GwsError::Other(anyhow::anyhow!("Failed to parse sendAs response: {e}")))?;View on GitHub (pinned to a3768d0e82)
Solutions
- Restore connectivity and re-run — the compose operation is idempotent until the final send call.
- Check proxy configuration for gmail.googleapis.com.
- If the account has no extra identities, this call still must succeed — a 403 here would be an Api error; transport errors mean network, not scopes.
- Enable `GOOGLE_WORKSPACE_CLI_LOG_FILE` to capture the reqwest root cause.
Defensive patterns
Strategy: retry
Try / catch
match fetch_send_as_identities(client, token).await {
Err(GwsError::Other(e)) if e.to_string().contains("Failed to fetch sendAs") && network_is_flaky() => {
tokio::time::sleep(Duration::from_secs(3)).await;
fetch_send_as_identities(client, token).await
}
other => other,
} Prevention
- Remember compose-time (+send/+reply) performs hidden sendAs lookups — test connectivity, not just the send call.
- send_with_retry handles transient errors; add one caller-side retry with backoff for long ops.
- Distinguish this transport error from scope problems: 403 comes back as GwsError::Api, not this.
When it happens
Trigger: Offline run of `gws gmail +send`/`+reply` (sendAs is fetched during compose); DNS/proxy/TLS failures to gmail.googleapis.com; connection resets repeating through every retry attempt.
Common situations: Sending mail from a train/plane connection, behind an unstable VPN, or in CI with restricted egress; the error surfaces at compose time even though the user thinks only SMTP-style sending is network-dependent.
Related errors
- Failed to fetch message: {e}
- People API request failed: {e}
- Failed to fetch attachment: {e}
- Failed to fetch user profile: {e}
- Pub/Sub pull failed: {e}
AI-assisted analysis of googleworkspace/cli@a3768d0e82 (2026-08-16).
Data as JSON: /api/errors/d16382595108641a.
Report an issue: GitHub.