Graphify-Labs/graphify · error · HTTPStatusError

{self.status_code} Error

Error message

{self.status_code} Error

What it means

worked/httpx's SyncResponse (or the raw Response model in worked/httpx/raw/models.py) implements raise_for_status() in the standard httpx style: when the response's status code is >= 400 (the is_error property), it raises HTTPStatusError with the terse message '<code> Error', carrying both the request and response objects. It is the caller's explicit opt-in — nothing throws this unless raise_for_status() is called on a 4xx/5xx reply.

Source

Thrown at worked/httpx/raw/models.py:108

    def json(self):
        return _json.loads(self.content)

    def read(self) -> bytes:
        return self.content

    @property
    def is_success(self) -> bool:
        return 200 <= self.status_code < 300

    @property
    def is_error(self) -> bool:
        return self.status_code >= 400

    def raise_for_status(self) -> None:
        if self.is_error:
            message = f"{self.status_code} Error"
            raise HTTPStatusError(message, request=self.request, response=self)

    @property
    def cookies(self) -> Cookies:
        jar = Cookies()
        for header in self.headers.get("set-cookie", "").split(","):
            if "=" in header:
                name, _, value = header.strip().partition("=")
                jar.set(name.strip(), value.split(";")[0].strip())
        return jar

    def __repr__(self):
        return f"<Response [{self.status_code}]>"

View on GitHub (pinned to 7fe58b0b0f)

Solutions

  1. Inspect response.status_code and response.text before calling raise_for_status() to understand the server's complaint
  2. Fix the underlying request: correct URL, valid auth header, appropriate body/params for the endpoint
  3. For 429/5xx, retry with exponential backoff (honor Retry-After) instead of failing on the first response
  4. If you prefer tolerance for specific codes, branch on response.is_error / status_code yourself rather than calling raise_for_status() unconditionally

Example fix

# before
resp = client.get(url)
resp.raise_for_status()  # 4xx/5xx → HTTPStatusError: '429 Error'

# after
resp = client.get(url)
if resp.status_code == 429:
    time.sleep(float(resp.headers.get('retry-after', 1)))
    resp = client.get(url)
resp.raise_for_status()
Defensive patterns

Strategy: try-catch

Validate before calling

resp = client.get(url)
if resp.is_error:
    log.warning('upstream %s body=%s', resp.status_code, resp.text[:500])
resp.raise_for_status()  # only after inspecting

Type guard

def is_retryable_status(resp) -> bool:
    """True for 429 and 5xx — candidates for backoff retry."""
    return resp.status_code == 429 or resp.status_code >= 500

Try / catch

try:
    resp = client.get(url)
    resp.raise_for_status()
except HTTPStatusError as e:
    status = e.response.status_code
    if status == 429 or status >= 500:
        time.sleep(backoff())
        retry = True
    elif status in (401, 403):
        raise AuthError('token expired or missing') from e
    else:
        raise

Prevention

When it happens

Trigger: Calling response.raise_for_status() after any request whose response status is >= 400: 401 on bad API keys, 404 on missing routes, 429 rate limiting, 500 server errors, etc.

Common situations: Hitting rate limits (429) without retry/backoff; expired or wrong auth tokens (401/403); pointing the client at the wrong base URL (404); upstream 5xx during incidents. Note this raw models layer does not parse a response body reason, so the message is only the numeric code.

Related errors


AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14). Data as JSON: /api/errors/efed9ce02cdf15cb. Report an issue: GitHub.