-
Notifications
You must be signed in to change notification settings - Fork 8.4k
fix: Validate complex mustache syntax during Check & Save #11461
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
Conversation
Add validation for complex mustache patterns (sections, conditionals,
partials, etc.) in the validate_prompt function when using mustache mode.
Previously, syntactically valid but unsupported patterns like
{{#section}}{{/section}} were accepted during save but caused runtime
errors with "Complex mustache syntax is not allowed".
Now the same validation that runs at runtime also runs during the
Check & Save phase, providing immediate feedback to users.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughAdds validation for Mustache template syntax before variable extraction in API utilities. A new test module comprehensively validates that simple variables are accepted while complex Mustache patterns (sections, conditionals, loops, etc.) are rejected with appropriate error messages. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 7✅ Passed checks (7 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Cristhianzl
left a comment
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.
lgtm
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (41.71%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #11461 +/- ##
==========================================
+ Coverage 34.88% 34.90% +0.02%
==========================================
Files 1420 1420
Lines 68215 68217 +2
Branches 9984 9984
==========================================
+ Hits 23797 23812 +15
+ Misses 43184 43171 -13
Partials 1234 1234
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Jira: LE-160
This pull request adds comprehensive unit tests to ensure that the
validate_promptfunction correctly rejects complex and invalid Mustache syntax during the validation phase, addressing a previous regression where such syntax was only caught at runtime. It also updates the validation logic to call a dedicated Mustache template security function before extracting variables, ensuring robust pre-validation.Testing improvements:
test_validate_prompt_mustache.pythat covers acceptance of simple Mustache variables, rejection of complex Mustache syntax (sections, conditionals, unescaped variables, partials, comments, etc.), invalid variable names, malformed syntax, and mixed content. This ensures that only simple, valid Mustache templates can be saved and that errors are caught early.Validation logic enhancements:
validate_promptinapi_utils.pyto callvalidate_mustache_templatebefore extracting variables, preventing complex Mustache syntax from being accepted during "Check & Save". [1] [2]Summary by CodeRabbit
Release Notes
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.