Preserve HTTP errors from streaming bundle downloads - #4138
Draft
henrymercer wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Warning
- Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.
Copilot review overview
🟢 Approval recommended
The behavioral change is well-scoped and validated with targeted tests; only a minor error-message consistency nit was identified.
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/tools-download.ts — response.statusCode is treated as potentially undefined (you already fall back to 0 for the… |
What changed in this PR
This PR improves error handling for streaming CodeQL bundle downloads by preserving HTTP status codes (notably 404) so callers can distinguish “missing bundle” from transient download failures, while ensuring the extraction directory is cleaned up on failures.
Changes:
- Throw a typed
HTTPErrorfrom streaming downloads when the HTTP status is not 200, and rethrow 404s without falling back to buffered download. - Always clean the destination extraction directory when the streaming path fails, before retrying/falling back/rethrowing.
- Add tests covering rethrow-on-404 behavior and fallback-on-5xx behavior, and tighten assertions around cleanup.
| File | Description |
|---|---|
| src/tools-download.ts | Preserves HTTP status via HTTPError, cleans extraction dir on streaming failure, and bypasses fallback for 404s. |
| src/tools-download.test.ts | Adds coverage for 404 rethrow (no retry) and 500 fallback, plus cleanup assertions. |
| lib/entry-points.js | Generated JS output (excluded by policy; not reviewed). |
Files excluded by content exclusion policy (1)
- lib/entry-points.js
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
203
to
209
| if (response.statusCode !== 200) { | ||
| // Discard the response body so that the connection can be released. | ||
| response.resume(); | ||
| throw new Error( | ||
| throw new HTTPError( | ||
| `Failed to download CodeQL bundle from ${codeqlURL}. HTTP status code: ${response.statusCode}.`, | ||
| response.statusCode ?? 0, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Preserve HTTP status codes when streaming CodeQL bundle downloads fail, so callers can distinguish a missing bundle from other download failures. Rethrow 404s without retrying the same URL through buffered downloading.
Clean up the extraction directory before retrying or rethrowing. Other streaming failures continue to fall back to downloading the bundle before extracting it.