fix(labels): use positive check for InstallationID#2506
fix(labels): use positive check for InstallationID#2506theakshaypant merged 2 commits intotektoncd:mainfrom
Conversation
Configure CreateCRDIncoming to set up secrets and GitProvider for direct webhook tests. Sets explicit provider type to prevent the controller from assuming GitHub App mode and looking for the global pipelines-as-code-secret which doesn't exist in direct webhook scenarios. Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
Change InstallationID validation from != -1 to > 0 for better semantic correctness. Signed-off-by: Akshay Pant <akshay.akshaypant@gmail.com>
Summary of ChangesHello @theakshaypant, 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 refines the handling of GitHub installation IDs by using a more semantically correct positive check, ensuring that only valid, positive IDs are processed. Additionally, it improves the testing infrastructure by enabling direct webhook testing within the Highlights
Changelog
Activity
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
|
🔍 PR Lint Feedback
|
|
/lgtm |
There was a problem hiding this comment.
Congrats @theakshaypant your PR Has been approved 🎉
✅ Pull Request Approved
Approval Status:
- Required Approvals: 1
- Current Approvals: 1
👥 Reviewers Who Approved:
| Reviewer | Permission Level | Approval Status |
|---|---|---|
| @chmouel | admin |
✅ |
📝 Next Steps
- Ensure all required checks pass
- Comply with branch protection rules
- Request a maintainer to merge using the
/mergecommand (or merge it
directly if you have repository permission).
Automated by the PAC Boussole 🧭
There was a problem hiding this comment.
Code Review
This pull request introduces two changes. First, it improves the validation for InstallationID by using a positive check (> 0) instead of != -1, which is clearer and more accurate given that installation IDs are positive integers. This is a good improvement for code clarity. Second, it adds support for direct webhook testing in the CreateCRDIncoming test helper function. This is achieved by creating the necessary secrets and GitProvider configuration when opts.DirectWebhook is enabled. While this is a valuable addition for testing, I've suggested an improvement to make the test more robust by explicitly checking for the required environment variables.
| token, _ := os.LookupEnv("TEST_GITHUB_TOKEN") | ||
| webhookSecret, _ := os.LookupEnv("TEST_EL_WEBHOOK_SECRET") | ||
| apiURL, _ := os.LookupEnv("TEST_GITHUB_API_URL") |
There was a problem hiding this comment.
Ignoring the boolean return from os.LookupEnv can lead to silent failures if the environment variables are not set, making tests harder to debug. It's better to explicitly check if the variables are present and fail the test with a clear message if they are missing.
token, ok := os.LookupEnv("TEST_GITHUB_TOKEN")
assert.Assert(t, ok, "TEST_GITHUB_TOKEN environment variable must be set for direct webhook tests")
webhookSecret, ok := os.LookupEnv("TEST_EL_WEBHOOK_SECRET")
assert.Assert(t, ok, "TEST_EL_WEBHOOK_SECRET environment variable must be set for direct webhook tests")
apiURL, ok := os.LookupEnv("TEST_GITHUB_API_URL")
assert.Assert(t, ok, "TEST_GITHUB_API_URL environment variable must be set for direct webhook tests")References
- When a function can fail or return an empty result, ensure both conditions are checked independently (e.g., with
||), as a condition that seems redundant might be a necessary, independent exit path.
📝 Description of the Change
👨🏻 Linked Jira
N/A
🔗 Linked GitHub Issue
N/A
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com
**💡You can use the script
./hack/add-llm-coauthor.shto automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.