-
Notifications
You must be signed in to change notification settings - Fork 116
fix: resolve templating placeholder evaluation bug #2264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: resolve templating placeholder evaluation bug #2264
Conversation
Summary of ChangesHello @chmouel, 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 focuses on enhancing the robustness and reliability of the templating logic by introducing a comprehensive suite of unit tests for the Highlights
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves test coverage for the ReplacePlaceHoldersVariables function from 49.0% to 83.7% by adding comprehensive unit tests. The changes focus on enhancing test coverage for templating functionality with various edge cases and data type scenarios.
Key Changes
- Added tests for nil parameter handling (rawEvent and headers)
- Added tests for CEL type conversions (numeric, boolean, array, object types)
- Added tests for error handling scenarios (invalid keys, missing dictionary placeholders)
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this 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 significantly improves test coverage for the templating functionality, which is a great addition. However, I've identified that several of the new test cases are written to confirm existing buggy behavior in ReplacePlaceHoldersVariables
rather than testing for the correct functionality. Specifically, tests involving nil
rawEvent
or nil
headers
have incorrect expectations because the implementation has an overly strict check (if rawEvent != nil && headers != nil
). My review comments point out these specific test cases and suggest how to correct them to properly expose and guide the fix for the underlying bug. Once these tests are corrected, they will be a valuable addition to the test suite.
gemini properly identified a bug in the implementation, let's hold on |
af8d3b7
to
b7447e8
Compare
/gemini review |
There was a problem hiding this 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 placeholder evaluation by relaxing an overly strict condition, ensuring body
, headers
, and files
placeholders are evaluated correctly even when some contexts are nil
. The addition of comprehensive unit tests is a significant improvement, greatly increasing test coverage and confidence in the change. I have one minor suggestion to improve code conciseness.
b7447e8
to
c9c096d
Compare
Fix overly strict condition in ReplacePlaceHoldersVariables that prevented correct evaluation of placeholders when rawEvent or headers were nil. Changes: - body.* placeholders now work when rawEvent != nil (regardless of headers) - headers.* placeholders now work when headers != nil (regardless of rawEvent) - files.* placeholders now work independently of rawEvent/headers Add comprehensive unit tests improving coverage from 49.0% to 88.9%: - Nil parameter handling scenarios - CEL type conversions (numeric, boolean, array, object, double, int, bytes) - Error paths for invalid keys and expressions - Edge cases for missing dictionary placeholders - Complex nested object and array access - Mixed scenarios combining dico, body, and header lookups Split tests into focused functions: - TestReplacePlaceHoldersVariables: exact-match tests for deterministic cases - TestReplacePlaceHoldersVariablesJSONOutput: flexible JSON serialization tests - TestReplacePlaceHoldersVariablesEdgeCases: complex nested access patterns 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Chmouel Boudjnah <[email protected]>
c9c096d
to
6408a34
Compare
🔍 PR Lint Feedback
|
it's a minor fix since it may never happen... |
Fix overly strict condition in ReplacePlaceHoldersVariables that prevented
correct evaluation of placeholders when rawEvent or headers were nil.
Changes:
Add comprehensive unit tests improving coverage from 49.0% to 86.0%:
initiali coverage was:
📝 Description of the Change
👨🏻 Linked Jira
https://issues.redhat.com/browse/SRVKP-8984
🔗 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-by
trailer to your commit message.For example:
Co-authored-by: Gemini [email protected]
Co-authored-by: ChatGPT [email protected]
Co-authored-by: Claude [email protected]
Co-authored-by: Cursor [email protected]
Co-authored-by: Copilot [email protected]
**💡You can use the script
./hack/add-llm-coauthor.sh
to automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:
,feat:
) matches the "Type of Change" I selected above.make test
andmake lint
locally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit install
toautomate these checks.