-
Notifications
You must be signed in to change notification settings - Fork 116
chore: Add eventEmitter parameter to NewInstallation & test case improvement #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @mathur07, 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 refines the GitHub App integration by enhancing error reporting and improving the robustness of repository URL parsing and token generation. It introduces an event emission mechanism for critical failures during token acquisition, standardizes how repository owner and name are extracted from URLs, and adds specific validation for GitHub repository path formats. These changes collectively aim to make the system more resilient, easier to debug, and more reliable in handling GitHub App installations.
Highlights
- Enhanced Error Visibility: An "eventEmitter" parameter has been added to the "NewInstallation" function and is used to emit events when GitHub App token generation fails, providing better insight into issues.
- Standardized URL Parsing: The "formatting.GetRepoOwnerSplitted" utility is now used for consistent and reliable parsing of repository URLs to extract owner and repository names.
- GitHub-Specific URL Validation: New validation ensures that GitHub repository URLs adhere to the expected "owner/repo" format, preventing issues with incorrectly formatted paths.
- Improved Token Generation Resilience: The system now gracefully handles failures during GitHub App token generation, returning the installation ID even if the token cannot be created.
- Comprehensive Test Coverage: New and updated test cases have been added to cover direct repository installation success, token generation failures, and various invalid URL scenarios, improving overall robustness.
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
-
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. ↩
There was a problem hiding this comment.
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 enhances error visibility by adding an event emitter for GitHub App token generation failures, improves URL parsing consistency, and expands test coverage. The changes are generally positive, but there is a significant issue in the new URL parsing logic that could cause failures for valid GitHub repository URLs. I've provided a detailed comment and a suggested fix for this issue.
2219f5e
to
c06a21f
Compare
/gemini review |
There was a problem hiding this comment.
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 enhances error handling by adding an eventEmitter
to NewInstallation
. This allows for emitting events when GitHub App token generation fails, improving visibility. The changes also include improved test cases, covering the new failure scenario and enhancing existing tests for clarity. I've identified one high-severity issue in the logging implementation that could lead to a panic.
/ok-to-test |
- Add eventEmitter parameter to NewInstallation for better error visibility - Emit events when GitHub App token generation fails - Add comprehensive test coverage for various scenarios - Handle token generation failures gracefully while returning installation ID - Keep simple, direct URL parsing approach for GitHub-specific validation
3df4fe7
to
8fb3fee
Compare
} | ||
|
||
func NewInstallation(req *http.Request, run *params.Run, repo *v1alpha1.Repository, gh *github.Provider, namespace string) *Install { | ||
func NewInstallation(req *http.Request, run *params.Run, repo *v1alpha1.Repository, gh *github.Provider, namespace string, eventEmitter *events.EventEmitter) *Install { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathur07 you've modified only token_test.go but this function is used elsewhere as well e.g. incoming.go and install.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and can you please explain what's the use case of adding eventEmitter there, I see you passed it nil in tests?
The changes are in reference to: Comment
Reference: Comment
📝 Description of the Change
🔗 Linked GitHub Issue
Fixes #
👨🏻 Linked Jira
🚀 Type of Change
fix:
)feat:
)feat!:
,fix!:
)docs:
)chore:
)refactor:
)enhance:
)deps:
)🧪 Testing Strategy
✅ Submitter Checklist
fix:
,feat:
) matches the "Type of Change" I selected above.make test
andmake lint
locally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit install
toautomate these checks.