-
Notifications
You must be signed in to change notification settings - Fork 296
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
Improve Jinja Template feedback and error handling #884
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…that don't have a result
…ewing, rendering, saving templates
…endent on payload
matiasb
approved these changes
Nov 28, 2022
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
brojd
pushed a commit
that referenced
this pull request
Sep 18, 2024
* Improve feedback so template errors are given to user * Add security error logging * Add limits for templates, payloads, results * Show popup error notification for webhook errors and template errors that don't have a result * Update tests * Split exceptions into warnings/errors to give more control when previewing, rendering, saving templates * Limit title lengths * Make TypeError a warning * Adjust title length limit * Remove length limiting on urlize since it is being done on template render * Fix tests * Add KeyError and ValueError to warnings * No longer enforcing json result when saving webhook in case it is dependent on payload * Add tests for expected exceptions coming from apply_jinja_template * Update changelog * Send raw post if template result is not JSON
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does:
When editing jinja templates for alert presentation or outgoing webhooks the UI was returning vague errors back to the console making it difficult for the user to correct their template. Also if errors were encountered during runtime exceptions were being raised which blocked the alert from being displayed in the UI. This PR improves that experience.
General Template Changes
JinjaTemplateError
range
function can no longer be usedJinjaTemplateError
orJinjaTemplateWarning
JinjaTemplateError
should block saving of the templateJinjaTemplateWarning
should be displayed but not block saving. The purpose of this is when templates are saved we don't always have a complete representation of the data that will be used, this allows for accessing fields in the data which may be present at runtime but are not present when the template is being written.Alert Group Template Editor
Save Templates
a notification will popup if any errors block saving (Errors will block saving, Warnings will not)Alert Groups
Outgoing Webhooks
Data
template has been relaxed.JinjaTemplateWarning
are allowed to be saved to allow data that is only available at runtime (Got 500 error when saving Outgoing Webhook #890)Data
template results in an error/warning it will be delivered as the content of the webhook instead of raising an exception.Which issue(s) this PR fixes:
#890
https://github.com/grafana/oncall-private/issues/1446
https://github.com/grafana/oncall-private/issues/1445
https://github.com/grafana/oncall-private/issues/1431
Checklist
CHANGELOG.md
updated