fix(runtime): surface malformed proxy env and base URL before client init#10545
Merged
Conversation
…init When proxy env vars (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY) contain malformed URLs — e.g. 'http://127.0.0.1:6153export' from a broken shell config — the OpenAI/httpx client throws a cryptic 'Invalid port' error that doesn't identify the offending variable. Add _validate_proxy_env_urls() and _validate_base_url() in auxiliary_client.py, called from resolve_provider_client() and _create_openai_client() to fail fast with a clear, actionable error message naming the broken env var or URL. Closes #6360 Co-authored-by: MestreY0d4-Uninter <MestreY0d4-Uninter@users.noreply.github.com>
0b0c0df to
a4dcf27
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvaged from PR #6403 by @MestreY0d4-Uninter. Contributor's authorship preserved.
When proxy env vars (
HTTP_PROXY,HTTPS_PROXY,ALL_PROXY) contain malformed URLs — e.g.http://127.0.0.1:6153exportfrom a broken shell config — the OpenAI/httpx client throws a crypticInvalid port: '6153export'error that doesn't identify the offending variable.Changes:
_validate_proxy_env_urls()— checks all 6 proxy env var names, fails fast with a clear error naming the broken variable_validate_base_url()— catches malformed custom endpoint URLs before they reach httpxauxiliary_client.py(no duplication), called fromresolve_provider_client()and_create_openai_client().mailmap+release.pyentries for MestreY0d4-UninterCompared to original PR #6403:
resolve_provider_client()Test plan:
tests/agent/test_proxy_and_url_validation.py— all passtests/agent/suite: 1142 passed, 6 pre-existing failures (unrelated)Closes #6360