fix: variables substitution issue on commit comment in GitLab#2391
Conversation
Summary of ChangesHello @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 Highlights
🧠 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 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
|
There was a problem hiding this comment.
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.
168b3ca to
966b8b3
Compare
|
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? |
|
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. |
c061817 to
10eaae4
Compare
22d6827 to
8dc6c90
Compare
|
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. |
|
#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) |
There was a problem hiding this comment.
fine for e2e test but can you test then that CEL expressions like body.object_attributes.note actually work?
There was a problem hiding this comment.
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>
81a28f3 to
9521ab1
Compare
|
/approve |
|
/lgtm |
There was a problem hiding this comment.
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
/mergecommand (or merge it
directly if you have repository permission).
Automated by the PAC Boussole 🧭
To make event payload available in
bodyvariable 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 whenbody.anyfieldis 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
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.