666ghj/MiroFish · error · FetchError
GitHub API response exceeded the size limit
Error message
GitHub API response exceeded the size limit
What it means
Raised by _read_response when the declared Content-Length is negative or exceeds MAX_HTTP_BYTES (1,000,000). The script deliberately refuses to buffer oversized bodies: GitHub's repo JSON is a few KB, so anything near 1 MB signals a wrong or malicious response, and the check on the header prevents allocating the read at all.
Source
Thrown at scripts/fetch_star_count.py:64
return FetchError("GitHub API request was denied")
if status == 404:
return FetchError("repository metadata was not found")
if status == 429:
return FetchError("GitHub API rate limit was exhausted")
if 500 <= status <= 599:
return FetchError("GitHub API is unavailable")
return FetchError("GitHub API request failed")
def _read_response(response: Any) -> bytes:
raw_length = response.headers.get("Content-Length")
if raw_length is not None:
try:
content_length = int(raw_length, 10)
except (TypeError, ValueError) as exc:
raise FetchError("GitHub API returned invalid response metadata") from exc
if content_length < 0 or content_length > MAX_HTTP_BYTES:
raise FetchError("GitHub API response exceeded the size limit")
payload = response.read(MAX_HTTP_BYTES + 1)
if len(payload) > MAX_HTTP_BYTES:
raise FetchError("GitHub API response exceeded the size limit")
return payload
def fetch_star_count(token: str, opener: Any | None = None) -> int:
if not token or len(token) > 4_096 or "\r" in token or "\n" in token:
raise FetchError("GITHUB_TOKEN is missing or invalid")
request = urllib.request.Request(
API_URL,
headers={
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {token}",
"User-Agent": "Repository-Star-History-Fetcher",
"X-GitHub-Api-Version": API_VERSION,View on GitHub (pinned to b5b53acc57)
Solutions
- Verify nothing is intercepting the request (proxy, VPN, captive portal) — the real GitHub repo payload is far below 1 MB.
- Confirm API_URL still targets a single repository endpoint (/repos/{owner}/{repo}) and was not repointed at a list endpoint.
- In tests, set Content-Length to a realistic small value or omit it entirely (the check only runs when the header is present).
Defensive patterns
Strategy: try-catch
Try / catch
try:
count = fetch_star_count(token)
except FetchError as exc:
if exc.args[0] == "GitHub API response exceeded the size limit":
# header declared an oversized body: never retry into an unknown proxy
raise Prevention
- Keep MAX_HTTP_BYTES sized to the real payload (repo JSON is ~5 KB; 1 MB is already generous).
- Do not raise the limit to make an intercepted response pass — find out what is returning megabytes for a repo lookup.
- Assert in CI that direct curl of the endpoint stays under a few KB so regressions surface before the script does.
When it happens
Trigger: A Content-Length header > 1000000 or < 0 on the response from https://api.github.com/repos/666ghj/MiroFish; a proxy returning an oversized error/captive-portal page; a test double that sets an unrealistic Content-Length.
Common situations: Captive portals or proxy block pages served with huge bodies; API URL changed to point at something that returns large payloads; tests that copy headers from a different endpoint.
Related errors
- GitHub API returned invalid response metadata
- GitHub API returned malformed JSON
- GITHUB_TOKEN is missing or invalid
- GitHub API network request failed
- GitHub API request could not be started
AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14).
Data as JSON: /api/errors/1def2086edc97c10.
Report an issue: GitHub.