Skip to content

fix: downloads proceeding without clear error for non-existent repositories#119

Merged
kubrickcode merged 1 commit into
mainfrom
develop/shlee/29
Nov 29, 2025
Merged

fix: downloads proceeding without clear error for non-existent repositories#119
kubrickcode merged 1 commit into
mainfrom
develop/shlee/29

Conversation

@kubrickcode

Copy link
Copy Markdown
Owner

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

@github-actions github-actions Bot added the improvement Improvements to existing features label Nov 29, 2025
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @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

  • Improved Error Handling: GitHub API 404 errors for non-existent repositories are no longer silently caught, preventing confusing downstream issues and providing clearer feedback.
  • Specific Error Messages: Clear, actionable error messages are now provided for various HTTP status codes: 404 (repository not found), 401 (authentication required), and 403 (access forbidden, with guidance on tokens/permissions).
  • Consistent Network Error Wrapping: Non-HTTP network errors (e.g., connection refused, DNS resolution, timeouts) are now consistently wrapped in a NetworkError for unified and predictable handling.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/pkg/pull/github.spec.ts
Comment thread src/pkg/pull/github.ts
…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
@kubrickcode

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/pkg/pull/github.spec.ts
@kubrickcode kubrickcode merged commit 9fc3658 into main Nov 29, 2025
4 checks passed
@kubrickcode kubrickcode deleted the develop/shlee/29 branch November 29, 2025 11:29
@kubrickcode

Copy link
Copy Markdown
Owner Author

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvements to existing features released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improved to prevent downloads when a 404 error occurs

1 participant