Skip to content

Commit e5bb86c

Browse files
ruromeroclaude
andauthored
fix: add missing proxy support to requestImages() (#447)
* fix: add missing proxy support to requestImages() requestImages() was the only request function in analysis.js that did not call addProxyAgent(), causing image analysis requests to bypass the configured HTTP proxy. This wraps the fetch options with addProxyAgent(options, opts) following the same pattern used by requestStack, requestComponent, requestStackBatch, and validateToken. Implements TC-3922 Assisted-by: Claude Code * test: replace proxy integration tests with addProxyAgent unit tests The proxy tests claimed to "verify agent is set correctly" but only asserted on the response body — the agent was never actually checked. Replace with direct unit tests for addProxyAgent() that verify: - HttpsProxyAgent is created with the correct proxy URL - Agent is set for both HTTP and HTTPS proxy URLs - Agent is set when proxy comes from environment variable - No agent is set when no proxy is configured Also fix MSW v2 handler format in requestImages integration tests (use HttpResponse.json() instead of the v1 res(ctx.json()) API). Remove requestStack proxy integration tests that were broken due to fake file paths — the proxy logic is now properly covered by the addProxyAgent unit tests. Implements TC-3922 Assisted-by: Claude Code * fix: add missing proxy support to requestImages() and restore analysis tests Add addProxyAgent() call to requestImages(), which was the only request function missing proxy support. Restore and fix all analysis tests that were excluded from CI via --grep --invert: migrate MSW v1 to v2 API, fix stale header/option names (ex-provider-1-token → trust-da-token), add temp file setup for requestStack/requestComponent tests, and add addProxyAgent unit tests with actual agent verification. Implements TC-3922 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f2d5d72 commit e5bb86c

3 files changed

Lines changed: 149 additions & 109 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"lint": "eslint src test --ext js",
3939
"lint:fix": "eslint src test --ext js --fix",
4040
"test": "c8 npm run tests",
41-
"tests": "mocha --config .mocharc.json --grep \".*analysis module.*\" --invert",
41+
"tests": "mocha --config .mocharc.json",
4242
"tests:rep": "mocha --reporter-option maxDiffSize=0 --reporter json > unit-tests-result.json",
4343
"pretest": "cp node_modules/tree-sitter-requirements/tree-sitter-requirements.wasm src/providers/tree-sitter-requirements.wasm && cp node_modules/tree-sitter-gomod/tree-sitter-gomod.wasm src/providers/tree-sitter-gomod.wasm",
4444
"precompile": "rm -rf dist",

src/analysis.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,17 @@ async function requestImages(imageRefs, url, html = false, opts = {}) {
207207
finalUrl.searchParams.append('recommend', 'false');
208208
}
209209

210-
const resp = await fetch(finalUrl, {
210+
const fetchOptions = addProxyAgent({
211211
method: 'POST',
212212
headers: {
213213
'Accept': html ? 'text/html' : 'application/json',
214214
'Content-Type': CYCLONEDX_JSON_MEDIA_TYPE,
215215
...getTokenHeaders(opts)
216216
},
217217
body: JSON.stringify(imageSboms),
218-
})
218+
}, opts)
219+
220+
const resp = await fetch(finalUrl, fetchOptions)
219221

220222
if (resp.status === 200) {
221223
let result;

0 commit comments

Comments
 (0)