Skip to content

fix: close HTTP response in pipes() and fix 9 documentation issues#1

Merged
sena-labs merged 3 commits into
mainfrom
claude/pensive-hawking-d4ed27
May 6, 2026
Merged

fix: close HTTP response in pipes() and fix 9 documentation issues#1
sena-labs merged 3 commits into
mainfrom
claude/pensive-hawking-d4ed27

Conversation

@sena-labs
Copy link
Copy Markdown
Owner

Description

This PR delivers one code fix and nine documentation corrections identified during a comprehensive codebase audit.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Documentation update

Checklist

  • I have read the CONTRIBUTING.md guidelines
  • All tests pass (python test_pipe.py — 249/249 ✓)
  • I have added tests for new functionality (if applicable)
  • I have updated CHANGELOG.md under [Unreleased]
  • I have updated documentation (if applicable)
  • My code follows the project's code style (PEP 8, type hints)
  • No secrets, API keys, or credentials are included in this PR

Related Issues

N/A — identified during internal audit.

What Changed and Why

Code Fix — pipes() HTTP response leak

pipes() was calling self._session.get() but never explicitly closing the response object. In happy-path flows response.json() drains the body and the connection is returned to the pool automatically, but if JSON decoding raised a ValueError/JSONDecodeError the socket could remain occupied until GC. Three affected code paths:

  1. 401/403/502 branch — reads response.json() then returns without closing
  2. except Exception handler — entered when response.json() on the success path fails
  3. except HTTPError handler — exc.response (same object) not closed

Fix: initialise response = None before the try block; add finally: if response is not None: response.close(). This guarantees connection release regardless of which path exits.

Documentation Fixes

File Issue Fix
PULL_REQUEST_TEMPLATE.md Test count 234/234 — only file missed in previous update 249/249
SECURITY.md Supported Versions table Markdown was malformed (rows fused onto one line, breaking GitHub rendering) Restored correct row-per-line format
README.md (Configuration) SYNC_PROVIDER_ICONS valve missing from Advanced table Added row with env var OPENROUTER_SYNC_ICONS, default true
README.md (Troubleshooting) HTTP 429 tip incorrectly suggested raising MAX_RETRIES — which does not retry HTTP errors, only network timeouts/connection failures Corrected to accurate description
README.md (Project Structure) Test count 234 249
TESTING.md Test count 234/234 (×2) 249/249
TESTING.md §3.2 Referenced non-existent model anthropic/claude-3.7-sonnet:thinking deepseek/deepseek-r1 (matches integration tests)
TESTING.md §9.1 FALLBACK_MODELS test ambiguous — did not clarify that the primary model is first in the models array Reworded to make primary/fallback distinction explicit
CONTRIBUTING.md Test count 234 249
bug_report.yml Pipe Version placeholder was "e.g. 1.0.0" (initial release) "e.g. 1.2.0"
CHANGELOG.md pipes() response-close fix not recorded in [Unreleased] Added entry

Reviewer Notes

  • The code change is purely additive (one response = None init and a three-line finally block). No logic changes.
  • All 249 unit tests pass with no modifications.
  • The MAX_RETRIES documentation fix is important for correctness: the old text could lead users to incorrectly believe that raising the retry count would mitigate rate-limit errors.

sena-labs and others added 2 commits May 5, 2026 03:52
Code fix:
- pipes(): initialize response=None before try-block and add
  finally: response.close() to guarantee the connection is returned
  to the session pool in every code path (auth errors, JSON decode
  failures, unexpected exceptions)

Documentation fixes:
- Update test count from 234 to 249 across README, TESTING, CONTRIBUTING,
  and PULL_REQUEST_TEMPLATE (all missed or newly identified references)
- Fix SECURITY.md Supported Versions table (malformed Markdown — rows
  were fused onto one line, breaking GitHub rendering)
- Add SYNC_PROVIDER_ICONS valve to README Advanced configuration table
- Correct HTTP 429 troubleshooting tip: MAX_RETRIES does not retry HTTP
  errors — it only retries on network timeouts and connection failures
- Update bug_report.yml Pipe Version placeholder from 1.0.0 to 1.2.0
- Clarify TESTING.md §9.1 FALLBACK_MODELS test: make explicit that the
  primary model is the first element in the models array
- Replace non-existent reasoning model example (claude-3.7-sonnet:thinking)
  with deepseek/deepseek-r1 in TESTING.md §3.2
- Add pipes() response-close fix entry to CHANGELOG [Unreleased]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 6, 2026 21:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a potential HTTP connection leak in Pipe.pipes() by always closing the requests response object, and applies multiple documentation/template updates to reflect current test counts and clarify configuration/troubleshooting guidance.

Changes:

  • Ensure the /models HTTP response in pipes() is always closed via a finally block.
  • Update docs/templates to reflect the current unit test count (249) and improve clarity in testing/troubleshooting instructions.
  • Fix Markdown rendering for the SECURITY.md supported versions table.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
openrouter_pipe.py Always closes the /models HTTP response to prevent connection pool leaks on error/early-return paths.
CHANGELOG.md Records the pipes() response-close fix under [Unreleased].
README.md Adds the SYNC_PROVIDER_ICONS valve row and corrects 429 retry guidance.
SECURITY.md Repairs malformed Markdown table formatting for supported versions.
TESTING.md Updates expected unit test count and clarifies fallback-model testing instructions.
CONTRIBUTING.md Updates unit test count reference.
.github/PULL_REQUEST_TEMPLATE.md Updates the checklist’s unit test count reference.
.github/ISSUE_TEMPLATE/bug_report.yml Updates the pipe version placeholder example.
.gitignore Adds ignore patterns for “Auto Claude” artifacts (scope expansion vs. PR description).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread openrouter_pipe.py
Comment on lines +317 to +319
finally:
if response is not None:
response.close()
Comment thread TESTING.md Outdated
- Add 3 unit tests (15o/15p/15q) to verify pipes() always calls
  response.close() via the finally block:
  · 15o: auth-error path (HTTP 401) — close() called once
  · 15p: JSON decode error path — close() called once
  · 15q: success path — close() called once
  This prevents future regressions of the connection-pool fix.

- Fix TESTING.md §0: replace "Must print 249/249 passed" with the
  actual output format the runner emits ("All tests passed! ✓" and
  "✗ Failed: 0"), addressing Copilot review comment.

- Update test count from 249 → 252 across README, CONTRIBUTING,
  TESTING, and PULL_REQUEST_TEMPLATE to reflect the 3 new tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sena-labs sena-labs merged commit c302bbf into main May 6, 2026
4 checks passed
@sena-labs sena-labs deleted the claude/pensive-hawking-d4ed27 branch May 7, 2026 08:24
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