Skip to content

Conversation

mathur07
Copy link
Contributor

@mathur07 mathur07 commented Sep 16, 2025

  • Add eventEmitter parameter to NewInstallation for better error visibility
  • Emit events when GitHub App token generation fails
  • Handle token generation failures gracefully while returning installation ID

The changes are in reference to: Comment
Reference: Comment

📝 Description of the Change

🔗 Linked GitHub Issue

Fixes #

👨🏻‍ Linked Jira

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Copy link

@gemini-code-assist gemini-code-assist bot left a 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

  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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@mathur07 mathur07 force-pushed the shumathu-KONFLUX-5929 branch from 2219f5e to c06a21f Compare September 16, 2025 19:27
@mathur07
Copy link
Contributor Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@chmouel
Copy link
Member

chmouel commented Sep 17, 2025

/ok-to-test

@pipelines-as-code pipelines-as-code bot added enhancement New feature or request github testing labels Sep 17, 2025
@mathur07 mathur07 changed the title chore: Add eventEmitter parameter to NewInstallation & test case improvement chore: Add eventEmitter parameter to NewInstallation Sep 17, 2025
@mathur07 mathur07 changed the title chore: Add eventEmitter parameter to NewInstallation chore: Add eventEmitter parameter to NewInstallation & test case improvement Sep 17, 2025
- 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
@mathur07 mathur07 force-pushed the shumathu-KONFLUX-5929 branch from 3df4fe7 to 8fb3fee Compare September 17, 2025 17:27
}

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 {
Copy link
Contributor

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

Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request github testing
Development

Successfully merging this pull request may close these issues.

3 participants