Skip to content

intercept response wrapper: raise_for_status() should return self for httpx parity #25

@aural-psynapse

Description

@aural-psynapse

Summary

The SDK's intercept wrapper around httpx.Response implements raise_for_status as -> None (_responses.py), where the underlying httpx.Response.raise_for_status returns Self.

This silently breaks the standard httpx idiom every consumer reaches for:

return c.get("/path").raise_for_status().json()

Inside an intercept_context, the patched response wraps the real one. The chained .raise_for_status() returns None, .json() is then called on None, and the agent fails with:

AttributeError: 'NoneType' object has no attribute 'json'

Reproduction

Any HTTP call inside provably.intercept_context(...) that uses the chained idiom. We hit this on every CRM/billing/support/orders/messaging tool until we worked around it.

Workaround

We split every chained call into three statements (tools.py — see _get_json/_post_json):

def _get_json(c, path):
    r = c.get(path)
    r.raise_for_status()
    return r.json()

This works but every consumer ends up writing the same helper. The SDK should match httpx's contract.

Proposed fix

def raise_for_status(self) -> "WrappedResponse":
    self._orig.raise_for_status()
    return self

(Same change in both wrapper variants.) One-line change, full backward compat.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions