Skip to content

fix(runtime): surface malformed proxy env before client init#6403

Closed
MestreY0d4-Uninter wants to merge 1 commit into
NousResearch:mainfrom
MestreY0d4-Uninter:fix/issue-6360-proxy-env-validation
Closed

fix(runtime): surface malformed proxy env before client init#6403
MestreY0d4-Uninter wants to merge 1 commit into
NousResearch:mainfrom
MestreY0d4-Uninter:fix/issue-6360-proxy-env-validation

Conversation

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor

Summary

  • detect malformed proxy environment variables before Hermes/OpenAI/httpx client initialization
  • raise a clear runtime error naming the broken proxy env var instead of surfacing only Invalid port
  • add regression tests for malformed inherited proxy URLs and malformed custom endpoint URLs

Root cause

I initially suspected a malformed persisted custom endpoint URL because the user-facing error was:

  • Invalid port: 6153export

But after the reporter shared their redacted config files, the diagnosis changed:

  • config.yaml was clean
  • auth.json was clean
  • I could not find any persisted 6153export value in uploaded config/auth data

I then reproduced the exact failure by setting a malformed proxy environment variable such as:

  • HTTP_PROXY=http://127.0.0.1:6153export

That triggers the same stack trace through httpx / openai client creation:

  • InvalidURL
  • Invalid port: '6153export'

So the stronger root cause for issue #6360 is malformed inherited proxy env, not a saved custom endpoint URL.

Fix

  • validate HTTP_PROXY, HTTPS_PROXY, ALL_PROXY (and lowercase variants) before creating OpenAI-compatible clients
  • validate both:
    • the main runtime client path in run_agent.py
    • the auxiliary/provider-resolution path in agent/auxiliary_client.py
  • produce a clear Hermes error message like:
    • Malformed proxy environment variable HTTP_PROXY='http://127.0.0.1:6153export'. Fix or unset your proxy settings and try again.

Validation

Direct reproduction used during investigation:

  • with malformed HTTP_PROXY=http://127.0.0.1:6153export
  • before fix: raw httpx.InvalidURL: Invalid port: '6153export'
  • after fix: clear Hermes RuntimeError identifying the broken proxy env var

Automated checks run locally:

  • pytest tests/run_agent/test_endpoint_and_proxy_validation.py -q -o addopts=
  • python -m py_compile run_agent.py agent/auxiliary_client.py tests/run_agent/test_endpoint_and_proxy_validation.py

Notes

Closes #6360

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

Refreshed this PR against current origin/main in a clean worktree, but with one important cleanup:

The old branch had accumulated stacked unrelated commits (fix(vision): allow codex auth in auto backend detection and a Docker follow-up). I rebuilt the branch from current main with only the proxy-validation fix commit, so the PR now matches its stated purpose again.

Validation run:

  • uv sync --extra dev
  • python3 -m py_compile agent/auxiliary_client.py run_agent.py
  • uv run pytest -o addopts='' tests/run_agent/test_endpoint_and_proxy_validation.py -q

Result:

  • branch now contains only the malformed-proxy/runtime hardening fix
  • focused validation passed on current main base
  • auxiliary-client conflict was resolved by preserving the current-main runtime signature and inserting the same proxy-env validation into the custom-endpoint path

This is now a much cleaner review unit for the actual issue this PR is meant to solve.

@MestreY0d4-Uninter MestreY0d4-Uninter force-pushed the fix/issue-6360-proxy-env-validation branch from 4fc121b to cc9adc1 Compare April 14, 2026 16:50
@MestreY0d4-Uninter MestreY0d4-Uninter force-pushed the fix/issue-6360-proxy-env-validation branch from cc9adc1 to 41bc069 Compare April 14, 2026 16:51
@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

Final validation pass on current main base is complete.

What I rechecked:

  • refreshed branch uses my GitHub-linked noreply identity (MestreY0d4-Uninter@users.noreply.github.com)
  • clean worktree validation
  • real tmux-based run in a clean Hermes environment (HERMES_HOME temp dir)
  • focused runtime hardening tests
  • current GitHub checks

Concrete results:

  • manual malformed-proxy probe produced the expected fail-fast error:
    • Malformed proxy environment variable HTTP_PROXY='http://127.0.0.1:6153export'...
  • uv run pytest -o addopts='' tests/run_agent/test_endpoint_and_proxy_validation.py -q
  • result: 12 passed
  • current GitHub checks: all green

I also rebuilt this branch so it now contains only the proxy/runtime hardening fix (dropping the unrelated stacked commits that had accumulated on the old branch).

This one is ready for review/merge.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #10545. Your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks for the thorough detective work tracking this down from the cryptic error to the proxy env var root cause — great issue investigation @MestreY0d4-Uninter!

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

Labels

None yet

Projects

None yet

2 participants