feat: implement proxy support CF-2437#196
Conversation
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Complexity | 1 medium |
🟢 Metrics 82 complexity · 0 duplication
Metric Results Complexity 82 Duplication 0
🟢 Coverage 82.12% diff coverage · +1.32% coverage variation
Metric Results Coverage variation ✅ +1.32% coverage variation Diff coverage ✅ 82.12% diff coverage 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.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
No description provided.