Skip to content

OLS-3736 fix IPv6 addresses in no-proxy causing invalid port error - #3033

Open
thoraxe wants to merge 3 commits into
openshift:mainfrom
thoraxe:fix/OLS-3736-ipv6-no-proxy
Open

OLS-3736 fix IPv6 addresses in no-proxy causing invalid port error#3033
thoraxe wants to merge 3 commits into
openshift:mainfrom
thoraxe:fix/OLS-3736-ipv6-no-proxy

Conversation

@thoraxe

@thoraxe thoraxe commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When ::1 (or any bare IPv6 address) is present in the cluster no-proxy list, the httpx mount-dict key was constructed as all://*::1, which httpx misparses — treating :1 as a port — raising "Invalid port: ':1'" and crashing the LLM connection health check.
  • Extracts _no_proxy_mount_key() in provider.py to wrap bare IPv6 addresses (detected by host.count(":") >= 2) in brackets per RFC 3986 § 3.2.2, producing all://[::1]. host:port entries (exactly one colon) and plain hostnames continue to use all://*<host>.

Test plan

  • make test-unit passes (1160 tests, 15 new/modified in providers file)
  • New unit tests cover: bare ::1, bare full IPv6, already-bracketed [::1], host:port, hostname, IPv4, CIDR, and mixed-list httpx client construction

Fixes: OLS-3736

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved proxy bypass handling for IPv6 addresses, including loopback and fully qualified formats.
    • Prevented connection setup errors when IPv6 addresses are included in proxy exclusions.
    • Preserved correct behavior for hostnames, IPv4 addresses, CIDR ranges, and hosts with ports.
  • Tests

    • Added coverage for IPv6 and other proxy exclusion formats.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9bc652a5-a3bf-4e86-ae80-2fdd6d63b707

📥 Commits

Reviewing files that changed from the base of the PR and between afb427f and 0ad0edd.

📒 Files selected for processing (2)
  • ols/src/llms/providers/provider.py
  • tests/unit/llms/providers/test_providers.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • ols/src/llms/providers/provider.py
  • tests/unit/llms/providers/test_providers.py

📝 Walkthrough

Walkthrough

The provider adds IPv6-aware httpx no-proxy mount keys, uses them during client construction, and adds unit and regression tests for IPv6, hostname, IPv4, CIDR, and host-port inputs.

Changes

IPv6 no-proxy handling

Layer / File(s) Summary
Mount key generation and client integration
ols/src/llms/providers/provider.py
Adds _no_proxy_mount_key for exact bracketed IPv6 matching and wildcard matching for other host formats. Uses the helper when configuring httpx no-proxy mounts.
No-proxy matching tests
tests/unit/llms/providers/test_providers.py
Tests IPv6, IPv6 CIDR, hostname, IPv4, CIDR, and host-port inputs. Tests client construction with IPv6 no-proxy hosts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: tisnik

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the IPv6 no-proxy defect and the resulting invalid port error.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
🧪 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.

@openshift-ci
openshift-ci Bot requested review from sriroopar and tisnik July 29, 2026 17:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ols/src/llms/providers/provider.py`:
- Around line 239-260: The _no_proxy_mount_key function incorrectly treats IPv6
CIDR entries as bare IPv6 literals. Detect CIDR values separately and return the
existing all://*<host> wildcard pattern for them, while retaining bracketed
exact-match handling for bare IPv6 addresses; add a regression test covering an
IPv6 CIDR such as 2001:db8::/32.

In `@tests/unit/llms/providers/test_providers.py`:
- Around line 173-205: Update each test_no_proxy_mount_key_* function with a ->
None return annotation and rewrite its docstring in imperative form. Also update
the nested MyProvider override methods to include appropriate parameter and
return type annotations plus Google-style imperative docstrings, preserving the
existing test behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7161237a-a481-47bd-a3da-e86ab6eee50a

📥 Commits

Reviewing files that changed from the base of the PR and between 1430287 and afb427f.

📒 Files selected for processing (2)
  • ols/src/llms/providers/provider.py
  • tests/unit/llms/providers/test_providers.py

Comment thread ols/src/llms/providers/provider.py
Comment thread tests/unit/llms/providers/test_providers.py Outdated

@sriroopar sriroopar 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.

Clean, well-scoped IPv6 fix with thorough test coverage — CIDR-before-IPv6 ordering is correct and no regressions.

@sriroopar

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2026
@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sriroopar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 30, 2026
@sriroopar

Copy link
Copy Markdown
Contributor

/retest

1 similar comment
@sriroopar

Copy link
Copy Markdown
Contributor

/retest

@red-hat-konflux

Copy link
Copy Markdown
Contributor

All PipelineRuns for this commit have already succeeded. Use /retest <pipeline-name> to re-run a specific pipeline or /test to re-run all pipelines.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 5b712fd and 2 for PR HEAD 058836a in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD d3f0286 and 1 for PR HEAD 058836a in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 555172b and 0 for PR HEAD 058836a in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/hold

Revision 058836a was retested 3 times: holding

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 1, 2026
@raptorsun

Copy link
Copy Markdown
Contributor

/test e2e-ols-cluster

@thoraxe

thoraxe commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

/hold cancel

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 0641fff and 2 for PR HEAD 058836a in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD abe81b9 and 1 for PR HEAD 058836a in total

@sriroopar sriroopar 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.

Root cause

PR #3033 (fix/OLS-3736-ipv6-no-proxy) branched off main at commit 1430287. Since then, a different PR merged into main:

PR #3033's branch was never rebased onto that change, so:

The pre-existing test at line 164 still calls the old 2-arg form:

_construct_httpx_client(False, False).
The new regression test this PR adds (test_construct_httpx_client_with_ipv6_in_no_proxy_hosts) 

copied that same old 2-arg call pattern. When CI runs the PR's branch merged against current main, both calls now pass 3 positional args (self + 2) into a method that only accepts 2 (self + use_async), producing exactly the TypeError you're seeing. This is also why the PR's own test-plan checkbox for make test-unit is unchecked — the author likely knows it's not green yet.

Fix :

Rebase the branch onto latest main, then update both call sites to drop the removed argument:

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 2ffea98 and 0 for PR HEAD 058836a in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/hold

Revision 058836a was retested 3 times: holding

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2026
thoraxe and others added 3 commits August 11, 2026 09:44
When ::1 (or any bare IPv6 address) appears in the cluster no-proxy
list, the HTTP client mount-dict key was constructed as all://*::1,
which httpx misparses — treating :1 as a port — and raises
"Invalid port: ':1'", crashing the LLM connection health check.

Extract _no_proxy_mount_key() in provider.py to wrap bare IPv6
addresses (detected by two or more colons) in brackets per RFC 3986
section 3.2.2, producing all://[::1]. host:port entries (exactly one
colon) and plain hostnames continue to use the all://*<host> pattern.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Fix _no_proxy_mount_key to detect CIDR entries (e.g. 2001:db8::/32)
  before the IPv6 colon-count check, so IPv6 CIDRs use the wildcard
  suffix pattern instead of being incorrectly bracketed as IPv6 literals
- Add test_no_proxy_mount_key_ipv6_cidr regression test for IPv6 CIDR
- Add -> None return annotations to all test_no_proxy_mount_key_* fns
- Rewrite test docstrings in imperative mood (fixes ruff D403 CI failure)
- Add type annotations and docstrings to nested MyProvider override methods

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Rebasing onto main picked up a prior change that dropped an argument
from _construct_httpx_client (now only takes use_async). The new
IPv6 regression test still called it with two positional args,
causing a TypeError in CI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@thoraxe
thoraxe force-pushed the fix/OLS-3736-ipv6-no-proxy branch from 058836a to 0ad0edd Compare August 11, 2026 13:58
@thoraxe

thoraxe commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and fixed the stale _construct_httpx_client call site that sriroopar flagged — the new IPv6 regression test was still calling it with the old 2-arg signature (False, False) after main dropped the second argument. Updated to _construct_httpx_client(False). All 16 tests in test_providers.py pass locally.

@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 11, 2026
@thoraxe

thoraxe commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

/hold cancel

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 11, 2026
@openshift-ci

openshift-ci Bot commented Aug 13, 2026

Copy link
Copy Markdown

@thoraxe: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/tls-scan 0ad0edd link true /test tls-scan

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants