Skip to content

fix: improve CLI download error handling [IDE-1690]#353

Merged
rrama merged 5 commits intomainfrom
fix/IDE-1690_improve-download-error-handling
Jan 29, 2026
Merged

fix: improve CLI download error handling [IDE-1690]#353
rrama merged 5 commits intomainfrom
fix/IDE-1690_improve-download-error-handling

Conversation

@rrama
Copy link
Copy Markdown
Contributor

@rrama rrama commented Jan 15, 2026

Description

  • Add HTTP status code validation in FileDownloadResponseHandler (only accept 2xx & 3xx responses, log response body for debugging).
  • Include download URL and status code in error messages.
  • Gracefully handle download failures in SnykStartup, but allow LS startup with existing binary if available.
  • Validate CLI binary exists before starting language server, with helpful error message suggesting to check Error Log when "Manage Binaries Automatically" is enabled.

Checklist

  • Read and understood the Code of Conduct and Contributing Guidelines.
  • Tests added and all succeed
  • Linted
  • CHANGELOG.md updated
  • Nah, too small a bug fix.
  • README.md updated, if user-facing
  • N/A

Screenshots / GIFs

Screenshot 2026-01-15 at 15 33 14 ^ I changed the log levels slightly, but close enough to the end result.

- Add HTTP status code validation in FileDownloadResponseHandler (only accept 2xx responses, log response body for debugging).
- Include download URL and status code in error messages.
- Gracefully handle download failures in SnykStartup, but allow LS startup with existing binary if available.
- Validate CLI binary exists before starting language server, with helpful error message suggesting to check Error Log when "Manage Binaries Automatically" is enabled.
@snyk-io
Copy link
Copy Markdown

snyk-io bot commented Jan 15, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@rrama rrama marked this pull request as ready for review January 26, 2026 13:29
@rrama rrama requested review from a team as code owners January 26, 2026 13:29
}
});
} catch (RuntimeException e) {
} catch (IllegalStateException | SWTException e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was intentional - a catch-all. maybe better to disable pmd here.

public File handleResponse(HttpResponse httpResponse) throws IOException {
int statusCode = httpResponse.getStatusLine().getStatusCode();

if (statusCode < 200 || statusCode > 299) {
Copy link
Copy Markdown
Contributor

@bastiandoetsch bastiandoetsch Jan 26, 2026

Choose a reason for hiding this comment

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

The second part is not correct: >399 would be an error, not >299

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The only way I could imagine us hitting this would be if we got redirected but didn't follow it (bad redirections would throw redirection exceptions). So if we see 3xx then we didn't download the CLI, so I would prefer to treat that as an error.

However, I don't think will ever happen, and rather than debate it I will just allow it and add a comment.

if (tempFile != null && tempFile.exists() && !tempFile.delete()) {
tempFile.deleteOnExit();
}
} catch (SecurityException e) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was also an intentional catch-all exception block. Wouldn't specify the exceptions here.

Also allow 3xx status codes.
@rrama rrama merged commit 5c430bb into main Jan 29, 2026
10 checks passed
@rrama rrama deleted the fix/IDE-1690_improve-download-error-handling branch January 29, 2026 16:38
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.

3 participants