tiangolo/fastapi · error · RuntimeError

response.text

Error message

response.text

What it means

Raised by get_graphql_response() in scripts/notify_translations.py:229 when a GitHub GraphQL request returns a non-200 HTTP status. The body text (response.text) is used as the RuntimeError message so the GitHub API error is surfaced verbatim. This path covers transport/auth failures distinct from GraphQL-level errors (which are handled at line 235).

Source

Thrown at scripts/notify_translations.py:229

        "after": after,
        "category_id": category_id,
        "discussion_number": discussion_number,
        "discussion_id": discussion_id,
        "comment_id": comment_id,
        "body": body,
    }
    response = httpx.post(
        github_graphql_url,
        headers=headers,
        timeout=settings.httpx_timeout,
        json={"query": query, "variables": variables, "operationName": "Q"},
    )
    if response.status_code != 200:
        logging.error(
            f"Response was not 200, after: {after}, category_id: {category_id}"
        )
        logging.error(response.text)
        raise RuntimeError(response.text)
    data = response.json()
    if "errors" in data:
        logging.error(f"Errors in response, after: {after}, category_id: {category_id}")
        logging.error(data["errors"])
        logging.error(response.text)
        raise RuntimeError(response.text)
    return cast(dict[str, Any], data)


def get_graphql_translation_discussions(
    *, settings: Settings
) -> list[AllDiscussionsDiscussionNode]:
    data = get_graphql_response(
        settings=settings,
        query=all_discussions_query,
        category_id=questions_translations_category_id,
    )
    graphql_response = AllDiscussionsResponse.model_validate(data)

View on GitHub (pinned to 3e8d1526d8)

Solutions

  1. Check the response body in the log line emitted just before the raise (scripts/notify_translations.py:228 logs response.text at ERROR).
  2. Refresh GITHUB_TOKEN / the GitHub App token and confirm it has repo + discussions read scope.
  3. If the body mentions 'rate limit', wait and retry; consider exponential backoff.
  4. For 5xx, retry after a short delay; consult https://www.githubstatus.com/.
Defensive patterns

Strategy: retry

Validate before calling

import os

def github_token_present() -> bool:
    return bool(os.environ.get("GITHUB_TOKEN"))

Try / catch

import time, httpx, logging

for attempt in range(4):
    try:
        data = get_graphql_response(settings=settings, query=q)
        break
    except RuntimeError as e:
        if attempt == 3:
            raise
        logging.warning(f"GraphQL HTTP error, retrying: {e}")
        time.sleep(2 ** attempt)

Prevention

When it happens

Trigger: notify_translations.main() issues GraphQL POSTs via httpx to https://api.github.com/graphql (scripts/notify_translations.py:218). Any response.status_code != 200 raises here — common causes: 401 invalid/expired token, 403 rate limit or scope, 5xx GitHub outage, network proxy returning non-200.

Common situations: GITHUB_TOKEN is expired, revoked, or lacks repo/discussion scope. Secondary rate limit hit during a burst of CI runs. GitHub incident. A corporate proxy intercepts the request.

Related errors


AI-assisted analysis of tiangolo/fastapi@3e8d1526d8 (2026-08-11). Data as JSON: /api/errors/dfa74ea2db867dd1. Report an issue: GitHub.