Skip to content

fix(exceptions): read the HTTP status off aiohttp-style responses - #1387

Merged
HareeshBahuleyan merged 2 commits into
mozilla-ai:mainfrom
JamMaster1999:fix/aiohttp-response-status
Sep 14, 2026
Merged

HareeshBahuleyan merged 2 commits into
mozilla-ai:mainfrom
JamMaster1999:fix/aiohttp-response-status

Conversation

@JamMaster1999

@JamMaster1999 JamMaster1999 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

google-genai's async client attaches an aiohttp.ClientResponse to the errors it raises, and aiohttp spells the status status, not status_code. _extract_status_code only read status_code, so every async Gemini 4xx/5xx classified by message alone and came back with status_code=None. This reads both spellings.

Split out of #1294, whose gemini half landed in #1381.

Tests: one new unit test in tests/unit/test_exception_handler.py that builds a response carrying status and no status_code. It fails on main (assert None == 400) and passes here. tests/unit/test_exception_handler.py, 86 passed. Pre-commit clean.

PR Type

  • 🐛 Bug Fix

Relevant issues

Split out of #1294.

Checklist

  • I understand the code I am submitting.
  • I have added unit tests that prove my fix/feature works
  • I have run this code locally and verified it fixes the issue.
  • New and existing tests pass locally
  • Documentation was updated where necessary (not applicable)
  • I have read and followed the contribution guidelines
  • AI Usage:
    • No AI was used.
    • AI was used for drafting/refactoring.
    • This is fully AI-generated.

AI Usage Information

  • AI Model used: Claude (Fable 5.1)

  • AI Developer Tool used: Claude Code

  • Any other info you'd like to share:

  • I am an AI Agent filling out this form (check box if true)

https://claude.ai/code/session_01546kUvB5GcyCkhQVSjpjbk

@github-actions github-actions Bot added the missing-template PR is missing required template checklist label Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f52e3e8f-e749-49ec-bc92-5c16221533fe

📥 Commits

Reviewing files that changed from the base of the PR and between dccdb7a and 6c50fde.

📒 Files selected for processing (2)
  • src/any_llm/utils/exception_handler.py
  • tests/unit/test_exception_handler.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

The exception handler now extracts integer HTTP status codes from either response.status_code or response.status. A unit test validates status recovery from an aiohttp-style response.

Changes

Exception status extraction

Layer / File(s) Summary
Status extraction and regression test
src/any_llm/utils/exception_handler.py, tests/unit/test_exception_handler.py
_extract_status_code checks status_code and status. The test verifies that convert_exception returns status code 400 when only response.status is set.

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 088db

The change correctly supports both response status attribute spellings and includes regression coverage.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: reading HTTP status values from aiohttp-style responses. It is concise and specific.
Description check ✅ Passed The description explains the bug, the implementation, the test coverage, the related issue, and the verification results. The required sections are present and the checklist is complete.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot removed the missing-template PR is missing required template checklist label Sep 11, 2026
@HareeshBahuleyan
HareeshBahuleyan requested a lite review from Copilot September 14, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The fix and corresponding test coverage address the reported issue with no unresolved blockers.

Pull request overview

Fixes async Gemini error handling by supporting aiohttp-style response status fields.

Changes:

  • Reads both status_code and status.
  • Adds unit coverage for aiohttp-style responses.
File summaries
File Summary
tests/unit/test_exception_handler.py Tests aiohttp-style status extraction.
src/any_llm/utils/exception_handler.py Extracts status from both supported attributes.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@JamMaster1999
JamMaster1999 deployed to integration-tests September 14, 2026 08:19 — with GitHub Actions Active
google-genai's async client attaches an aiohttp.ClientResponse to the
errors it raises, and aiohttp spells the status `status`, not
`status_code`. `_extract_status_code` only read `status_code`, so every
async Gemini 4xx/5xx classified by message alone and reported
`status_code=None`. Read both spellings.

Claude-Session: https://claude.ai/code/session_01546kUvB5GcyCkhQVSjpjbk
@HareeshBahuleyan
HareeshBahuleyan force-pushed the fix/aiohttp-response-status branch from 6c50fde to 5fc8f9c Compare September 14, 2026 08:20
@HareeshBahuleyan
HareeshBahuleyan deployed to integration-tests September 14, 2026 08:31 — with GitHub Actions Active
@HareeshBahuleyan
HareeshBahuleyan deployed to integration-tests September 14, 2026 08:31 — with GitHub Actions Active
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/any_llm/utils/exception_handler.py 93.79% <100.00%> (-5.43%) ⬇️

... and 26 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HareeshBahuleyan
HareeshBahuleyan merged commit afe8b97 into mozilla-ai:main Sep 14, 2026
14 checks passed
@github-actions github-actions Bot added the 1.28.0 Included in release 1.28.0 label Sep 18, 2026

This branch was successfully deployed

1 active deployment
integration-tests — 088db8da Deployed Sep 14, 2026 by HareeshBahuleyan via run-docs-tests #2950
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.28.0 Included in release 1.28.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants