Skip to content

fix(github): support lightweight tags for GitOps commands#2407

Merged
chmouel merged 1 commit intotektoncd:mainfrom
zakisk:SRVKP-10467-fix-gitops-comment-on-lightweight-tag
Feb 11, 2026
Merged

fix(github): support lightweight tags for GitOps commands#2407
chmouel merged 1 commit intotektoncd:mainfrom
zakisk:SRVKP-10467-fix-gitops-comment-on-lightweight-tag

Conversation

@zakisk
Copy link
Copy Markdown
Member

@zakisk zakisk commented Jan 22, 2026

When GitOps command /test or /retest is triggered on a lightweight tag, it was causing an error in ParsePayload because GitHub treats annotated and lightweight tags differently:

  • Annotated tags: ref object type is "tag", requires GetTag API call to resolve the commit SHA
  • Lightweight tags: ref object type is "commit", the ref already contains the commit SHA directly

The fix uses a switch statement to handle both cases and returns an error for unexpected object types.

Also adds:

  • Unit tests for lightweight tag and invalid object type scenarios
  • E2E test coverage for both annotated and lightweight tags
  • LightweightTag option in test framework

https://issues.redhat.com/browse/SRVKP-10467

📝 Description of the Change

👨🏻‍ Linked Jira

🔗 Linked GitHub Issue

Fixes #

🚀 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

@zakisk zakisk requested a review from chmouel January 22, 2026 07:51
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @zakisk, 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 provides a crucial fix for GitOps commands, enabling them to function correctly when invoked on lightweight Git tags. Previously, these commands would encounter errors because the system did not differentiate between annotated and lightweight tags in GitHub's API responses. The changes introduce robust parsing logic to handle both tag types, ensuring that the correct commit SHA is always resolved. This enhancement significantly improves the reliability and usability of GitOps workflows, particularly for projects that utilize lightweight tags.

Highlights

  • Bug Fix for GitOps Commands on Lightweight Tags: Resolved an issue where GitOps commands like /test or /retest failed when triggered on lightweight tags due to GitHub's differing treatment of annotated and lightweight tags. The system now correctly identifies and processes both types.
  • Enhanced Tag Parsing Logic: Implemented a switch statement in parse_payload.go to distinguish between 'tag' (annotated) and 'commit' (lightweight) object types, ensuring the correct commit SHA is retrieved for each.
  • Improved Test Coverage: Added new unit tests to cover scenarios for lightweight tags and invalid object types. E2E tests have also been expanded to include coverage for both annotated and lightweight tags, enhancing overall reliability.
  • Test Framework Update: Introduced a LightweightTag option in the test framework to facilitate the creation and testing of lightweight tags in E2E environments.
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

pipelines-as-code bot commented Jan 22, 2026

🔍 PR Lint Feedback

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

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 2274e06 fix(github): support lightweight tags for GitOps commands

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

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 a fix to support lightweight tags for GitOps commands, which were previously causing errors. The core change in pkg/provider/github/parse_payload.go correctly uses a switch statement to handle both annotated and lightweight tags by inspecting the ref object type. The accompanying unit tests in pkg/provider/github/parse_payload_test.go are well-structured and cover the new logic, including positive and negative cases. The E2E test in test/github_tag_gitops_test.go is also updated to cover both tag types.

My review has identified a critical issue in a test helper function that could cause a panic due to a nil pointer dereference. Additionally, I've noted a reduction in the E2E test's assertions, which weakens its validation. I've provided suggestions to address both points.

@zakisk zakisk force-pushed the SRVKP-10467-fix-gitops-comment-on-lightweight-tag branch from d94bc40 to 3461ff0 Compare January 22, 2026 09:15
@zakisk
Copy link
Copy Markdown
Member Author

zakisk commented Jan 22, 2026

/gemini-review

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 26, 2026

failure is accurate, can reproduce locally

@zakisk zakisk force-pushed the SRVKP-10467-fix-gitops-comment-on-lightweight-tag branch from 24aad61 to 8227a63 Compare February 11, 2026 06:39
When GitOps command `/test` or `/retest` is triggered on a
lightweight tag, it was causing an error in ParsePayload because
GitHub treats annotated and lightweight tags differently:

- Annotated tags: ref object type is "tag", requires GetTag API
  call to resolve the commit SHA
- Lightweight tags: ref object type is "commit", the ref already
  contains the commit SHA directly

The fix uses a switch statement to handle both cases and returns
an error for unexpected object types.

Also adds:
- Unit tests for lightweight tag and invalid object type scenarios
- E2E test coverage for both annotated and lightweight tags
- LightweightTag option in test framework

https://issues.redhat.com/browse/SRVKP-10467

Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
@zakisk zakisk force-pushed the SRVKP-10467-fix-gitops-comment-on-lightweight-tag branch from 8227a63 to 2274e06 Compare February 11, 2026 10:46
@chmouel chmouel merged commit f7d229d into tektoncd:main Feb 11, 2026
13 checks passed
@zakisk zakisk deleted the SRVKP-10467-fix-gitops-comment-on-lightweight-tag branch February 11, 2026 11:55
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