Skip to content

fix(cli): fail fast when --proxy has no or an unsupported protocol - #1843

Merged
mrgrain merged 3 commits into
aws:mainfrom
lemon0333:fix/validate-proxy-protocol
Aug 18, 2026
Merged

fix(cli): fail fast when --proxy has no or an unsupported protocol#1843
mrgrain merged 3 commits into
aws:mainfrom
lemon0333:fix/validate-proxy-protocol

Conversation

@lemon0333

Copy link
Copy Markdown
Contributor

Fixes #453

--proxy localhost:1234 (a proxy address without a protocol) appeared to fail silently. proxy-agent only rejects a missing/unsupported protocol lazily, on the first request, so the real error (Unsupported protocol for proxy URL) was only visible with -vvv, and users otherwise saw a misleading downstream failure (e.g. "need credentials").

This validates the proxy address up front in ProxyAgentProvider.create() and throws a clear, actionable error, reusing proxy-agent's own exported supported-protocol map (so the accepted set can't drift):

  • no protocol / unparseable (localhost:1234, 1.2.3.4:8080) → Invalid proxy address '<addr>': it must be a URL that includes a protocol, e.g. 'http://<addr>'
  • unsupported protocol (ftp://…) → Unsupported protocol '<proto>' in proxy address '<addr>'. Supported protocols are: …

A valid address (http://…, https://…, socks5://…, pac+http://…) is unchanged. Added unit tests for validateProxyAddress and ProxyAgentProvider.create() (10 tests, all passing).

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

The proxy-agent library only rejects a proxy address with a missing or
unsupported protocol lazily, on the first request, so `--proxy localhost:1234`
appeared to fail silently (or later with a misleading credentials error) and
the real reason was only visible with -vvv.

Validate the proxy address up front in ProxyAgentProvider.create() and throw a
clear, actionable error, reusing proxy-agent's own supported-protocol map.

Fixes aws#453
The proxy address setting is unset when no --proxy is given and can surface
at runtime as an empty string or empty array; validating it unconditionally
broke unrelated commands with a spurious 'Invalid proxy address' error. Guard
the validation on a non-empty string.
auto-merge was automatically disabled August 18, 2026 07:30

Head branch was pushed to by a user without write access

@codecov-commenter

codecov-commenter commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.34%. Comparing base (88f6ad1) to head (0f721a1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1843      +/-   ##
==========================================
+ Coverage   90.31%   90.34%   +0.02%     
==========================================
  Files          80       80              
  Lines       12159    12195      +36     
  Branches     1725     1732       +7     
==========================================
+ Hits        10982    11018      +36     
  Misses       1143     1143              
  Partials       34       34              
Flag Coverage Δ
suite.unit 90.34% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rix0rrr
rix0rrr deployed to integ-approval August 18, 2026 13:37 — with GitHub Actions Active
@mrgrain
mrgrain added this pull request to the merge queue Aug 18, 2026
Merged via the queue into aws:main with commit da37001 Aug 18, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI & toolkit: --proxy must include a protocol

4 participants