zed-industries/zed · error · FetchError
Failed to connect to Sentry API: {error.reason}
Error message
Failed to connect to Sentry API: {error.reason} What it means
Raised by api_get() in script/select-sentry-crash-candidates when urllib raises URLError (anything other than an HTTP-level error): the request to the Sentry host never completed. Reasons include DNS resolution failure, connection refused, TLS handshake errors, proxy failures, and timeouts (a 30s socket timeout surfaces here as URLError wrapping the timeout).
Source
Thrown at script/select-sentry-crash-candidates:63
def api_get(path: str, token: str):
url = f"{SENTRY_BASE_URL}{path}"
request = urllib.request.Request(url)
request.add_header("Authorization", f"Bearer {token}")
request.add_header("Accept", "application/json")
try:
with urllib.request.urlopen(request, timeout=30) as response:
return json.loads(response.read().decode("utf-8"))
except urllib.error.HTTPError as error:
body = error.read().decode("utf-8", errors="replace")
try:
detail = json.loads(body).get("detail", body)
except (json.JSONDecodeError, AttributeError):
detail = body
raise FetchError(f"Sentry API returned HTTP {error.code} for {path}: {detail}")
except urllib.error.URLError as error:
raise FetchError(f"Failed to connect to Sentry API: {error.reason}")
def fetch_issues(token: str, organization: str, limit: int, query: str):
encoded_query = urllib.parse.quote(query)
path = (
f"/organizations/{organization}/issues/"
f"?limit={limit}&sort=freq&query={encoded_query}"
)
return api_get(path, token)
def fetch_latest_event(token: str, issue_id: str):
return api_get(f"/issues/{issue_id}/events/latest/", token)
def parse_int(value, fallback=0) -> int:
try:
return int(value)View on GitHub (pinned to bc538def45)
Solutions
- From the same environment run: curl -sS -o /dev/null -w '%{http_code}' https://sentry.io/api/0/ to confirm egress
- Set HTTPS_PROXY/HTTP_PROXY (and NO_PROXY where needed) if a corporate proxy is required
- Check DNS (getent hosts sentry.io) and TLS trust (proxy MITM CA installed into the trust store)
- Check status.sentry.io for an outage before debugging locally
Defensive patterns
Strategy: retry
Validate before calling
# Cheap connectivity pre-flight before the run
import socket, ssl
def can_reach_sentry(host: str = "sentry.io") -> bool:
try:
with socket.create_connection((host, 443), timeout=5):
return True
except OSError:
return False Try / catch
for attempt in range(3):
try:
return api_get(path, token)
except FetchError as error:
if "Failed to connect" not in str(error):
raise
time.sleep(2 ** attempt) # transient DNS/proxy/TLS failures often clear Prevention
- Run a TCP/TLS reachability check to sentry.io before batch jobs
- Set HTTPS_PROXY/HTTP_PROXY in CI environments that require an egress proxy
- Keep the existing timeout=30 so connection failures surface instead of hanging
When it happens
Trigger: Running the script where egress to sentry.io is blocked (CI sandbox, offline machine, VPN split-tunnel); HTTPS_PROXY required but unset; DNS failing for the Sentry host; the API base URL overridden to an unreachable internal host; Sentry outage.
Common situations: CI job without corporate proxy env vars; laptop on a network with a TLS-intercepting proxy whose CA is not trusted; /etc/resolv.conf broken in a container; status.sentry.io reporting an incident.
Related errors
- Failed to connect to Sentry API: {err.reason}
- Slack webhook returned {response.status_code}: {response.tex
- GraphQL failed after {retries} retries: {last_err}
- Sentry API returned HTTP {error.code} for {path}: {detail}
- Sentry API returned HTTP {err.code} for {path}: {detail}
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/e805ab4906dad777.
Report an issue: GitHub.