Skip to content

fix: variables substitution issue on commit comment in GitLab#2391

Merged
chmouel merged 1 commit intotektoncd:mainfrom
zakisk:SRVKP-9458-comment-commit-payload-not-substituted
Feb 19, 2026
Merged

fix: variables substitution issue on commit comment in GitLab#2391
chmouel merged 1 commit intotektoncd:mainfrom
zakisk:SRVKP-9458-comment-commit-payload-not-substituted

Conversation

@zakisk
Copy link
Copy Markdown
Member

@zakisk zakisk commented Jan 13, 2026

To make event payload available in body variable we've Event field in Event struct to store raw event and be processed by ReplacePlaceHoldersVariables func but in GitLab where commit comment event is handled Event field is not assigned because Event struct is built inside handleCommitCommentEvent func and created new Event instance while Event raw field is assigned early in ParsePayload and it was causing issue that when body.anyfield is accessed in commit comment event, they weren't not being substituted at all. this PR uses already processed event for Event field to be used further in event processing.

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

📝 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

@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 addresses a bug in how GitLab commit comment events are processed. By ensuring that the handleCommitCommentEvent function uses an already initialized event object, it resolves an issue where variable substitution was not occurring correctly in PipelineRuns. This change improves the reliability of event handling for GitLab users.

Highlights

  • GitLab Commit Comment Event Handling: The handleCommitCommentEvent function now correctly utilizes the processedEvent object passed to it, rather than initializing a new one. This ensures that raw event data is properly assigned and variables are substituted as expected in PipelineRuns.
  • Test Improvement: An assertion assert.Assert(t, got.Event != nil) has been added to TestParsePayload to ensure the event object is not nil after parsing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 13, 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:

  • 9521ab1 fix: variables substitution issue on commit comment in GitLab

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 effectively resolves a bug in GitLab commit comment event handling that prevented variable substitution in PipelineRuns. The issue stemmed from handleCommitCommentEvent re-initializing processedEvent, thereby losing the raw event payload set earlier in ParsePayload.

The fix is direct and correct: it modifies handleCommitCommentEvent to accept the existing processedEvent as a parameter, ensuring the raw event data is preserved. This change is mirrored in the function's call site.

Additionally, the pull request commendably includes an update to the test suite. A new assertion, assert.Assert(t, got.Event != nil), has been added to TestParsePayload to verify that the Event field is not nil in the returned structure. This is an excellent addition that directly tests the fix and helps prevent future regressions.

Overall, the changes are clean, well-targeted, and the approach is sound. The code quality is good, and the fix is well-tested.

@zakisk zakisk force-pushed the SRVKP-9458-comment-commit-payload-not-substituted branch from 168b3ca to 966b8b3 Compare January 13, 2026 14:01
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 14, 2026

what about an e2e test that test the issue so we know this is fixed with this patch?

@zakisk
Copy link
Copy Markdown
Member Author

zakisk commented Jan 16, 2026

what about an e2e test that test the issue so we know this is fixed with this patch?

the reason I didn't wrote E2E is that the bug was obvious that event raw payload wasn't passed in events struct which was supposed to be there. it wasn't kind of complex bug?

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 16, 2026

so I am not sure what does this fix? the jira mentions the steps to reproduce, if you can't reproduce it just let know the user?

@zakisk
Copy link
Copy Markdown
Member Author

zakisk commented Jan 16, 2026

so I am not sure what does this fix? the jira mentions the steps to reproduce, if you can't reproduce it just let know the user?

yeah, sorry for not making PR description clear, made it clear now please see it. it was just my opinion to not have E2E let me know if you still think that it's required.

@zakisk zakisk force-pushed the SRVKP-9458-comment-commit-payload-not-substituted branch from c061817 to 10eaae4 Compare January 19, 2026 06:03
@zakisk zakisk requested a review from chmouel January 20, 2026 06:16
@zakisk zakisk force-pushed the SRVKP-9458-comment-commit-payload-not-substituted branch 2 times, most recently from 22d6827 to 8dc6c90 Compare January 20, 2026 10:00
@theakshaypant
Copy link
Copy Markdown
Member

Might be out of scope for this PR but do we not face the same issue as #2355 for commit comments? I.e., missing certain fields in the body on gitops comments.

@zakisk
Copy link
Copy Markdown
Member Author

zakisk commented Jan 20, 2026

#2355 is about missing fields in event payload whereas this is about storing raw payload in event struct to be used as source for dynamic variable substitution.

}
assert.NilError(t, err)
if tt.want != nil {
assert.Assert(t, got.Event != nil)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fine for e2e test but can you test then that CEL expressions like body.object_attributes.note actually work?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

then for that we need E2E (I will write)

Fixes commit comment event handling to use the already initialized
processedEvent instead of creating a new one, ensuring raw event
data is properly assigned in event and processed to substitute
variables in PipelineRuns.

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

Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
@zakisk zakisk force-pushed the SRVKP-9458-comment-commit-payload-not-substituted branch from 81a28f3 to 9521ab1 Compare February 19, 2026 10:15
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 19, 2026

/approve

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 19, 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 @zakisk 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 🧭

@chmouel chmouel merged commit cf0e0f7 into tektoncd:main Feb 19, 2026
14 checks passed
@zakisk zakisk deleted the SRVKP-9458-comment-commit-payload-not-substituted branch February 19, 2026 11:43
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.

3 participants