{"record":{"id":"d16382595108641a","repo":"googleworkspace/cli","slug":"failed-to-fetch-sendas-settings-e","errorCode":null,"errorMessage":"Failed to fetch sendAs settings: {e}","messagePattern":"Failed to fetch sendAs settings: (.+?)","errorType":"exception","errorClass":"GwsError","httpStatus":null,"severity":"error","filePath":"crates/google-workspace-cli/src/helpers/gmail/mod.rs","lineNumber":461,"sourceCode":"\n#[derive(Debug)]\nstruct SendAsIdentity {\n    mailbox: Mailbox,\n    is_default: bool,\n}\n\n/// Fetch all send-as identities from the Gmail settings API.\nasync fn fetch_send_as_identities(\n    client: &reqwest::Client,\n    token: &str,\n) -> Result<Vec<SendAsIdentity>, GwsError> {\n    let resp = crate::client::send_with_retry(|| {\n        client\n            .get(\"https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs\")\n            .bearer_auth(token)\n    })\n    .await\n    .map_err(|e| GwsError::Other(anyhow::anyhow!(\"Failed to fetch sendAs settings: {e}\")))?;\n\n    if !resp.status().is_success() {\n        let status = resp.status().as_u16();\n        let body = resp\n            .text()\n            .await\n            .unwrap_or_else(|_| \"(error body unreadable)\".to_string());\n        return Err(build_api_error(\n            status,\n            &body,\n            \"Failed to fetch sendAs settings\",\n        ));\n    }\n\n    let body: Value = resp\n        .json()\n        .await\n        .map_err(|e| GwsError::Other(anyhow::anyhow!(\"Failed to parse sendAs response: {e}\")))?;","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/googleworkspace/cli/blob/a3768d0e82ad83cca2da97724e46bea4ff0e6dbd/crates/google-workspace-cli/src/helpers/gmail/mod.rs#L443-L479","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match fetch_send_as_identities(client, token).await {\n    Err(GwsError::Other(e)) if e.to_string().contains(\"Failed to fetch sendAs\") && network_is_flaky() => {\n        tokio::time::sleep(Duration::from_secs(3)).await;\n        fetch_send_as_identities(client, token).await\n    }\n    other => other,\n}","preventionTips":["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."],"tags":["gmail","sendas","network","reqwest","compose"],"backgroundTag":"http-request-failed","analyzedSha":"a3768d0e82ad83cca2da97724e46bea4ff0e6dbd","analyzedAt":"2026-08-16T19:51:46.516Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}