Skip to content

Map ssl.SSLError to ReadError and WriteError in AnyIOStream - #1396

Merged
Kludex merged 2 commits into
mainfrom
map-anyio-ssl-error
Dec 4, 2026
Merged

Kludex merged 2 commits into
mainfrom
map-anyio-ssl-error

Conversation

@Kludex

@Kludex Kludex commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Add ssl.SSLError to the exception mappings in AnyIOStream.read() (ReadError) and AnyIOStream.write() (WriteError).

anyio.streams.tls.TLSStream only translates SSLSyscallError and SSLEOFError, re-raising other ssl.SSLErrors (such as mid-stream record layer / bad MAC alerts) raw. AnyIOStream.start_tls() already mapped ssl.SSLError to ConnectError, and both SyncStream (via OSError) and TrioStream (via trio.SSLStream wrapping ssl.SSLError in BrokenResourceError) already mapped mid-stream TLS errors to ReadError / WriteError, leaving AnyIOStream.read() and write() as the only paths leaking raw ssl.SSLError.

Addresses the mid-stream ssl.SSLError leak reported in #854.

Session: pi --session 01a24058-cc48-76fc-a013-84da8cb42ccf

View guided diff

@veria-ai

veria-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T15:46:16.590767Z cc7b4a2 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.

@codspeed

codspeed Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing map-anyio-ssl-error (1989da8) with main (9e06d74)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/httpx2/test_exceptions.py Resolved
@Kludex
Kludex merged commit 1f6c6b2 into main Dec 4, 2026
20 checks passed
@Kludex
Kludex deleted the map-anyio-ssl-error branch December 4, 2026 15: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.

1 participant