fix: downloads proceeding without clear error for non-existent repositories#119
Conversation
Summary of ChangesHello @kubrickcode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the robustness and user-friendliness of repository downloads by overhauling the error handling mechanism for GitHub API interactions. Previously, certain API failures, particularly 404 errors, were suppressed, leading to obscure problems later in the download process. The updated implementation now explicitly catches and interprets various HTTP status codes and network issues, providing immediate and context-rich feedback to the user. This change ensures that users receive clear guidance on how to resolve issues related to repository access, authentication, or network connectivity, thereby streamlining the debugging process and improving overall system reliability. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly improves error handling by providing clear, actionable error messages for failed GitHub API requests, which is a great enhancement for user experience. Instead of failing silently, the code now throws specific errors for different HTTP statuses like 404, 401, and 403.
My review focuses on two main areas. First, I've suggested a refactoring in src/pkg/pull/github.ts to use a switch statement for handling HTTP status codes. This improves code readability and adheres to the repository's style guide regarding conditional nesting depth. Second, I've pointed out that the new tests in src/pkg/pull/github.spec.ts don't actually verify the new error handling logic in getGitHubDefaultBranch. I've provided a detailed recommendation and an example for rewriting the tests to mock the external API calls, which will ensure the new logic is robust and well-tested. Overall, these are excellent changes that will be even stronger with the suggested improvements to testing.
…tories Previously, 404 errors from GitHub API were silently caught and default branch "main" was returned, causing downloads to proceed with confusing downstream errors Improved to fail early with clear error messages for each HTTP status code - 404: guide to verify repository existence and access - 401/403: suggest token provision or permission check - Network errors: wrapped in NetworkError for consistent handling fix #29
9e2cbb2 to
6847586
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly improves error handling by failing early with specific, actionable error messages for API and network failures, which is a great improvement. However, the accompanying tests in github.spec.ts are critically flawed as they do not actually test the new error handling logic within the getGitHubDefaultBranch function. Additionally, there is a minor violation of the repository's style guide regarding code nesting depth in github.ts that should be addressed by refactoring.
|
🎉 This PR is included in version 1.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Previously, 404 errors from GitHub API were silently caught and default branch "main" was returned, causing downloads to proceed with confusing downstream errors
Improved to fail early with clear error messages for each HTTP status code
fix #29