Skip to content

feat: implement proxy support CF-2437#196

Open
nedaKaighobadi wants to merge 6 commits into
mainfrom
add-proxy-support
Open

feat: implement proxy support CF-2437#196
nedaKaighobadi wants to merge 6 commits into
mainfrom
add-proxy-support

Conversation

@nedaKaighobadi
Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 26, 2026

Up to standards ✅

🟢 Issues 1 medium

Results:
1 new issue

Category Results
Complexity 1 medium

View in Codacy

🟢 Metrics 82 complexity · 0 duplication

Metric Results
Complexity 82
Duplication 0

View in Codacy

🟢 Coverage 82.12% diff coverage · +1.32% coverage variation

Metric Results
Coverage variation +1.32% coverage variation
Diff coverage 82.12% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (275e52a) Report Missing Report Missing Report Missing
Head commit (e8d70d6) 6779 (+150) 1656 (+124) 24.43% (+1.32%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#196) 151 124 82.12%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces proxy support for Axios and telemetry requests by reading VS Code configuration and environment variables. The feedback suggests ensuring proxy settings are initialized immediately upon extension activation, passing authorization headers to the HTTP proxy agent while removing invalid TLS options, and configuring Axios to not throw on non-2xx status codes so that Segment can handle HTTP errors properly.

Comment thread src/extension.ts
Comment thread src/common/proxy.ts Outdated
Comment thread src/common/proxy.ts
@nedaKaighobadi nedaKaighobadi marked this pull request as ready for review May 26, 2026 08:26
@nedaKaighobadi nedaKaighobadi requested a review from a team as a code owner May 26, 2026 08:26
Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

While this PR implements the core proxy support requested in CF-2437, it fails to meet the explicit requirement for NO_PROXY support. This omission, combined with the use of a global Axios agent, means the extension will attempt to route all traffic through the proxy, likely breaking connectivity for local or internal hosts.

The file src/common/proxy.ts is high-risk; it contains complex logic for proxy resolution and agent creation but lacks sufficient unit tests (30.3% coverage). Additionally, several logic errors in the Segment HTTP client and URL parsing could lead to runtime crashes or telemetry failures. Although Codacy rates the PR as 'Up to Standards', the security trade-off of disabling TLS verification globally and the architectural issue in src/extension.ts (exceeding line limits) should be addressed before merging.

About this PR

  • The implementation completely ignores the NO_PROXY environment variable. This was an explicit requirement in the JIRA ticket and is necessary for users in environments with internal service exclusions.
  • The PR description is empty. Please provide context regarding the manual testing performed, especially since automated test coverage for the proxy logic is currently low.
1 comment outside of the diff
src/extension.ts

line 207 🟡 MEDIUM RISK
The activate function has 127 lines of code, exceeding the 100-line limit. Refactoring this into purpose-specific initialization functions (telemetry, proxy listener, UI flags) would improve readability and testability.

Test suggestions

  • Missing recommended test scenario: Verify resolveProxyUrl prioritizes VS Code settings over environment variables
  • Missing recommended test scenario: Verify SSL verification is disabled globally via NODE_TLS_REJECT_UNAUTHORIZED when proxyStrictSSL is false
  • Missing recommended test scenario: Verify proxy settings are updated dynamically when vscode.workspace.onDidChangeConfiguration is triggered for 'http'
  • Missing recommended test scenario: Verify NO_PROXY exclusions are respected for outbound requests
  • Missing recommended test scenario: Verify ProxiedSegmentHTTPClient correctly routes Segment telemetry through the configured axios proxy
  • Unit tests for configureAxiosProxy covering no proxy, HTTP/HTTPS protocols, and authentication headers
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Missing recommended test scenario: Verify resolveProxyUrl prioritizes VS Code settings over environment variables
2. Missing recommended test scenario: Verify SSL verification is disabled globally via NODE_TLS_REJECT_UNAUTHORIZED when proxyStrictSSL is false
3. Missing recommended test scenario: Verify proxy settings are updated dynamically when vscode.workspace.onDidChangeConfiguration is triggered for 'http'
4. Missing recommended test scenario: Verify NO_PROXY exclusions are respected for outbound requests
5. Missing recommended test scenario: Verify ProxiedSegmentHTTPClient correctly routes Segment telemetry through the configured axios proxy
6. Unit tests for configureAxiosProxy covering no proxy, HTTP/HTTPS protocols, and authentication headers
Low confidence findings
  • The current manual implementation using 'tunnel' and 'http-proxy-agent' requires more maintenance than the 'proxy-agent' library, which handles NO_PROXY and environment variable prioritization out of the box.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread src/common/proxy.ts
Comment thread src/common/proxy.ts Outdated
Comment thread src/common/proxy.ts
Comment thread src/common/proxy.ts Outdated
Comment thread src/common/proxy.ts
Comment thread src/common/proxy.ts Outdated
Comment thread src/common/proxy.ts Outdated
@nedaKaighobadi nedaKaighobadi requested a review from alerizzo May 26, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants