Skip to content

[Hackathon] fix(http): a proxy variable without a scheme (HTTPS_PROXY=proxy.corp:3128) is ignored, and every command then fails as a service outage #673

Open

Description

@Yazan-O

Verified against (commit SHA or released version)

commit a18d37c (main, v0.15.0), built from source and run on Node 22.23.4, Windows 11, 2026-10-26.

Discord Username / User ID

yazan030803

What does this improvement do?

A proxy variable written without a scheme, e.g. HTTPS_PROXY=proxy.corp:3128, is thrown away: the CLI prints one warning, ignores the proxy, connects directly, and on a network where only the proxy can reach the internet every command then fails with exit 10 "fetch failed ... Service is temporarily unavailable", telling the user to report an outage.

host:port with no scheme is a common way to set these variables on corporate machines and CI runners, and curl accepts it (it assumes http:// when no scheme is given), so the same value works for other tools on the box and fails only for testsprite. In CI logs and for coding agents, the exit-10 "service unavailable" line is what gets acted on, not the warning above it.

Repro (a local proxy on port P, an API host only the proxy can reach):

HTTP_PROXY / HTTPS_PROXY Result
http://127.0.0.1:P request goes through the proxy, exit 0
127.0.0.1:P warning: ignoring proxy environment (could not initialize proxy agent): Invalid URL, then exit 10
proxy.corp.example:P warning: ... Invalid URL protocol, then exit 10
HTTPS_PROXY=proxy.corp.example:3128 testsprite auth status
# warning: ignoring proxy environment (could not initialize proxy agent): Invalid URL protocol
# ... exit 10 (service unavailable)

Details / implementation notes

Root cause.

  • src/lib/proxy.ts:47 builds new EnvHttpProxyAgent() with no options, so undici reads the raw env value and requires a full URL; host:port throws.
  • proxy.ts:49-57 catches that, warns, and falls back to the default (direct) dispatcher.
  • The existing tests can't see it: proxy.ts checks deps.env for whether a proxy is set, but undici reads process.env, so the tests never build an agent from their own value.

Proposed fix (only proxy.ts):

  • Read https_proxy/HTTPS_PROXY and http_proxy/HTTP_PROXY from deps.env with undici's lower-case-first order, prefix http:// when the value has no scheme://, and pass them explicitly: new EnvHttpProxyAgent({ httpProxy, httpsProxy }). NO_PROXY handling stays with undici.
  • Keep the try/catch and warning for values that are really invalid (e.g. socks5://).
  • This also makes deps.env the real input, so the tests exercise the value they set.

Tests: a scheme-less HTTPS_PROXY installs the agent with no warning; http:// values are unchanged; an unsupported scheme still warns and falls back; one subprocess test runs auth status through a local CONNECT proxy with a scheme-less value and expects exit 0. Fails on main, passes with the fix.

Not a duplicate: #119 / PR #169 added proxy support (tested only http:// values); #433 / PR #634 cover TLS inspection, block pages and 407 behind a working proxy; #434 is the tunnel data connection. Searched open and closed issues and PRs for scheme-less proxy values, Invalid URL and EnvHttpProxyAgent.

I'd like to fix this myself once it's accepted. I could not add the hackathon / needs-triage labels (no permission on an issue opened through the API); could a maintainer add them?

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. added
    needs-triage
    hackathon
    on Oct 26, 2026
  2. fyZhang66 commented on Oct 30, 2026

    @fyZhang66
    Contributor

    Confirmed on v0.15.0, thanks @Yazan-O. maybeInstallProxyAgent builds a bare EnvHttpProxyAgent(), so undici reads the raw value from process.env and throws on host:port; the catch then falls back to a direct connection, which on a proxy-only network turns into exit 10 "service unavailable". Accepted at low priority, scope:

    • Read https_proxy / HTTPS_PROXY / http_proxy / HTTP_PROXY from deps.env in undici's lower-case-first order, prefix http:// when the value has no scheme:// (curl's convention), and pass them as { httpProxy, httpsProxy }. Pass noProxy from the same env too, so the agent has one source. Leave NO_PROXY semantics to undici.
    • Keep the try/catch, the warning and the direct fallback for values that are really invalid (socks5:// and the like). No new error code.
    • Tests (each must fail before the fix): a scheme-less HTTPS_PROXY installs the agent with no warning; a scheme-less http_proxy likewise; an http:// value is unchanged; socks5:// still warns and falls back; one subprocess test runs auth status through a local CONNECT proxy given as 127.0.0.1:<port> and expects exit 0 (the local-proxy harness in test.local.spec.ts is the model).

    No new dependency. Comment /assign to claim it.

  3. added
    accepted
    and removed
    needs-triage
    on Oct 30, 2026
  4. Yazan-O commented on Oct 30, 2026

    @Yazan-O
    ContributorAuthor

    (mistyped command, see the next comment)

  5. Yazan-O commented on Oct 30, 2026

    @Yazan-O
    ContributorAuthor

    /assign

  6. added
    in-progress
    on Oct 30, 2026
  7. testsprite-hob commented on Oct 30, 2026

    @testsprite-hob

    Assigned to @Yazan-O. Thanks for taking this on. (2 more slots available.)

    Your open assigned issues (1/3):
    (none)

  8. removed
    in-progress
    on Nov 9, 2026
  9. testsprite-hob commented on Nov 9, 2026

    @testsprite-hob

    @Yazan-O, your claim expired after 48 hours (counted from when this issue was accepted) without a linked PR. This issue is open for others now, and you're welcome to /assign again if it's still free.

  10. OkeyAmy commented on Nov 10, 2026

    @OkeyAmy
    Contributor

    /assign

  11. added
    in-progress
    on Nov 10, 2026
  12. testsprite-hob commented on Nov 10, 2026

    @testsprite-hob

    Assigned to @OkeyAmy. Thanks for taking this on. (1 more slot available.)

    Your open assigned issues (2/3):

  13. testsprite-hob commented on Nov 11, 2026

    @testsprite-hob

    @OkeyAmy, your claim on this issue expires in about 24 hours unless you open a PR that links it (for example, Closes #673 or Part of #673). You can re-claim later with /assign if the issue is still free.

  14. removed
    in-progress
    on Nov 12, 2026
  15. testsprite-hob commented on Nov 12, 2026

    @testsprite-hob

    @OkeyAmy, your claim expired after 48 hours without a linked PR. This issue is open for others now, and you're welcome to /assign again if it's still free.

  16. akramcodez commented on Nov 12, 2026

    @akramcodez

    /assign

  17. added
    in-progress
    on Nov 12, 2026
  18. testsprite-hob commented on Nov 12, 2026

    @testsprite-hob

    Assigned to @akramcodez. Thanks for taking this on. (2 more slots available.)

    Your open assigned issues (1/3):
    (none)

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

Metadata

Metadata

Assignees

Labels

acceptedhackathonin-progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions