Skip to content

feat: preserve response headers on HTTPError and RateLimitError - #55

Merged
TheRealAgentK merged 5 commits into
release/2.1.0from
na/feat/http-error-headers
Nov 1, 2026
Merged

TheRealAgentK merged 5 commits into
release/2.1.0from
na/feat/http-error-headers

Conversation

@NinosMan

@NinosMan NinosMan commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ExecutionContext.fetch() exposes response headers on successful FetchResponse objects, but it discarded them when it raised HTTPError or RateLimitError. Integrations could not read provider headers that are needed to handle some failures. For example, JobAdder returns HTTP 409 with an X-Allow-Duplicates override code (Autohive-AI/autohive-integrations#548).

Refs #54

Changes

  • HTTPError has a new optional, keyword-only headers argument and a headers attribute. It defaults to {} and stores a copy of the input.
  • fetch() passes the response headers when it raises HTTPError for a non-2xx response, and when it raises RateLimitError for HTTP 429.
  • No change to the positional constructor arguments, the exception message (HTTP {status}: {message}), retry_after, or the retry behaviour.
  • Version is now 2.1.0. Release notes are added and the API docs are regenerated.

Exposure

Headers are never added to str(exc). The lambda wrapper serializes unhandled exceptions with type(e).__name__, str(e) and the traceback only, so headers do not get to the platform result, the logs or the agent unless an integration returns them on purpose. A regression test uses a distinctive header value to check that it does not appear in str(exc), repr(exc) or exc.message.

Testing

  • SDK suite: 96 passed, 100% coverage. 8 new tests cover header retention for 409 and 429, empty headers when none are given, the keyword-only argument, the copy behaviour and the message regression.
  • Compatibility check across autohive-integrations: every action of the 73 integrations that call fetch() and pin SDK ~=2.0.x (1,226 actions) ran with SDK 2.0.1 and with this branch. A local server failed each request with 409 or 429 and sent a sentinel header.
    • 1,210 actions raised a real HTTPError / RateLimitError through fetch(). With 2.1.0, exc.headers had the sentinel on all of them. The other 16 do not call fetch().
    • The result the platform gets was identical between SDK versions for all 1,226 actions. The comparison masked only per-call timestamps and random OAuth values, which also change between two runs of 2.0.1.
    • The sentinel did not appear in a result or an exception message with either SDK version.
    • The existing integration unit tests gave identical results with both SDK versions (5,684 passed).
    • Not covered: the 15 integrations that pin ~=1.0.2, and the private integrations repo.

Notes for reviewers

  • This PR targets release/2.1.0, which is cut from the 2.0.1 tag. It does not target master, which is now on 3.0.0.dev0 and still has the User-Agent change that 2.0.1 reverted. After the release, a separate PR will cherry-pick this change onto master.
  • Integrations pinned to ~=2.0.0 or ~=2.0.1 do not get 2.1.0 automatically. An integration gets it only when its pin is changed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T20:32:02.760902Z 264b9be PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

ExecutionContext.fetch() exposed headers on successful responses but
discarded them when raising. Integrations such as JobAdder need provider
headers (for example X-Allow-Duplicates on HTTP 409) to handle failures.

- Add an optional keyword-only `headers` argument and attribute to
  HTTPError, defaulting to an empty dict.
- Pass response headers from fetch() for non-2xx responses and for 429.
- Keep the exception message, positional arguments, retry_after and
  retry behaviour unchanged, so headers never reach str(exc).
- Add release notes and regenerate API docs.

Refs #54
@NinosMan
NinosMan force-pushed the na/feat/http-error-headers branch from 264b9be to 0bec393 Compare November 1, 2026 20:42
@TheRealAgentK
TheRealAgentK self-requested a review November 1, 2026 21:17
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Coverage — 8e61ebe (ci: support release branch naming) by @TheRealAgentK

Total coverage: 100%

File Stmts Miss Cover Missing
src/autohive_integrations_sdk/__init__.py 2 0 100%
src/autohive_integrations_sdk/integration.py 359 0 100%

@TheRealAgentK TheRealAgentK left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TheRealAgentK
TheRealAgentK merged commit 53dd192 into release/2.1.0 Nov 1, 2026
1 check passed
@TheRealAgentK
TheRealAgentK deleted the na/feat/http-error-headers branch November 1, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants