Skip to content

fix(labels): use positive check for InstallationID#2506

Merged
theakshaypant merged 2 commits intotektoncd:mainfrom
theakshaypant:fix-webhook-ci
Feb 25, 2026
Merged

fix(labels): use positive check for InstallationID#2506
theakshaypant merged 2 commits intotektoncd:mainfrom
theakshaypant:fix-webhook-ci

Conversation

@theakshaypant
Copy link
Copy Markdown
Member

📝 Description of the Change

  • Configure CreateCRDIncoming to support direct webhook testing by setting up secrets and GitProvider configuration. This explicitly sets the provider type to prevent the controller from incorrectly assuming GitHub App mode.
  • Replace InstallationID validation from != -1 to > 0 for clearer intent, since installation IDs are positive integers.

👨🏻‍ Linked Jira

N/A

🔗 Linked GitHub Issue

N/A

🚀 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

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer 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.sh to automatically add
these co-author trailers to your commits.

✅ 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

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>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @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 CreateCRDIncoming function, which is crucial for robust validation of webhook-based integrations.

Highlights

  • Installation ID Validation: The validation for InstallationID has been updated from checking if it is not equal to -1 to checking if it is greater than 0. This change improves clarity as installation IDs are positive integers.
  • Direct Webhook Testing Configuration: The CreateCRDIncoming function in the test suite has been enhanced to support direct webhook testing. This involves setting up secrets and explicitly configuring the GitProvider type to prevent the controller from incorrectly assuming GitHub App mode.
Changelog
  • pkg/kubeinteraction/labels.go
    • Changed the condition for event.InstallationID from != -1 to > 0 for better clarity and correctness.
  • test/pkg/github/crd.go
    • Added conditional logic to configure secrets and GitProvider settings when opts.DirectWebhook is true, enabling direct webhook testing.
    • Explicitly set the GitProvider.Type to "github" to ensure correct webhook handling and prevent fallback to GitHub App mode during direct webhook tests.
Activity
  • The author has confirmed that this is a bug fix.
  • End-to-end tests have been performed for the changes.
  • AI assistance from Claude was used for generating commit messages.
  • The author has ensured commit messages are clear and follow project guidelines.
  • Local make test and make lint checks were run.
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.

@pipelines-as-code
Copy link
Copy Markdown

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🎫 Jira reference

Add a Jira reference in the description using one of the following formats:

  • https://issues.redhat.com/browse/SRVKP-<number>

If no SRVKP ticket exists yet, link a GitHub issue instead (e.g., Fixes #123).
Minor housekeeping PRs without Jira coverage can skip this after confirming with reviewers.


🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 5bdced7 test(github): add DirectWebhook support in CRD helper
  • a4da04c fix(labels): use positive check for InstallationID

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 25, 2026

/lgtm

Copy link
Copy Markdown

@pipelines-as-code pipelines-as-code bot left a comment

Choose a reason for hiding this comment

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

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 /merge command (or merge it
    directly if you have repository permission).

Automated by the PAC Boussole 🧭

Copy link
Copy Markdown

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

Comment on lines +87 to +89
token, _ := os.LookupEnv("TEST_GITHUB_TOKEN")
webhookSecret, _ := os.LookupEnv("TEST_EL_WEBHOOK_SECRET")
apiURL, _ := os.LookupEnv("TEST_GITHUB_API_URL")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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
  1. 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.

@theakshaypant theakshaypant merged commit 59a480c into tektoncd:main Feb 25, 2026
12 checks passed
@theakshaypant theakshaypant deleted the fix-webhook-ci branch February 25, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants