usestrix/strix · error · CodexAuthError

unavailable

unavailable

Error message

unavailable: {exc}

What it means

CodexAuthError with code `unavailable` is raised when the HTTP request to OpenAI's OAuth token endpoint (https://auth.openai.com/oauth/token) fails at the transport layer — DNS failure, connection refused, TLS error, or timeout (30s). It signals a network/availability problem, not an auth problem: the request never got an HTTP response.

Source

Thrown at strix/config/codex.py:232

    values = query.get(key)
    return values[0] if values else None


def _post_form(payload: dict[str, str]) -> dict[str, Any]:
    detail = ""
    try:
        with requests.post(
            TOKEN_URL,
            data=payload,
            headers={"Accept": "application/json"},
            timeout=_TOKEN_TIMEOUT,
        ) as response:
            status_code = response.status_code
            body = response.content
            if status_code >= 400:
                detail = response.text[:300]
    except requests.RequestException as exc:
        raise CodexAuthError("unavailable", str(exc)) from exc
    if status_code >= 400:
        raise CodexAuthError("token_http_error", f"HTTP {status_code}: {detail}")
    data = json.loads(body or b"{}")
    if not isinstance(data, dict):
        raise CodexAuthError("bad_response", "token endpoint returned non-object")
    return data


def _record_from_token_response(
    data: dict[str, Any], refresh_fallback: str | None = None
) -> dict[str, Any]:
    access = data.get("access_token")
    # A refresh response may omit refresh_token when it isn't rotated; keep the old one.
    refresh = data.get("refresh_token") or refresh_fallback
    expires_in = data.get("expires_in")
    if not isinstance(access, str) or not access:
        raise CodexAuthError("bad_response", "token response missing access_token")
    if not isinstance(refresh, str) or not refresh:

View on GitHub (pinned to 8551339130)

Solutions

  1. Check connectivity to the endpoint: `curl -I https://auth.openai.com/oauth/token` from the same machine/user
  2. Configure proxy env vars (HTTPS_PROXY) if a corporate proxy is required, or排除 auth.openai.com from proxy blocking
  3. Retry the operation — this is a transient availability error; re-run `strix auth login` or let the next `get_valid_token()` call retry refresh
  4. If the outage persists, switch the scan to an API-key provider (non-Codex LLM config) until auth.openai.com is reachable
Defensive patterns

Strategy: retry

Validate before calling

import socket, urllib.parse

def token_endpoint_reachable(timeout: float = 5.0) -> bool:
    host = urllib.parse.urlparse("https://auth.openai.com").hostname
    try:
        socket.create_connection((host, 443), timeout=timeout).close()
        return True
    except OSError:
        return False

Try / catch

from strix.config.codex import CodexAuthError, get_valid_token

try:
    access, account = get_valid_token()
except CodexAuthError as e:
    if e.code == "unavailable":
        # transport-level failure: safe to retry with backoff
        ...  # schedule retry / surface 'check network' to user
    raise

Prevention

When it happens

Trigger: Any call to `exchange_code(code, verifier)` during `strix auth login` or `refresh_tokens(refresh_token)` during token refresh, when `requests.post(TOKEN_URL, ...)` raises a `requests.RequestException` (ConnectionError, Timeout, SSLError) — e.g. no internet, corporate proxy blocking auth.openai.com, or the endpoint being down.

Common situations: Running scans on an air-gapped or proxied network; VPN dropping mid-refresh; transient auth.openai.com outages; misconfigured HTTPS_PROXY/HTTP_PROXY env vars; captive portals.

Related errors


AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15). Data as JSON: /api/errors/1932733f3dc44b7a. Report an issue: GitHub.