Merged
Conversation
Users writing `{{ rule_name }}` inside a top-level template (`templates.<name>.title`,
`body`, `email_body_html`) or inside a `throttle.key` template previously got
an empty string, because rule_name was only injected into the notifier-level
contexts (email subject_template, telegram body_template, etc.). Congto hit
this trying to build a Telegram alert with the rule name in the body.
Inject the synthetic `rule_name` String into the rendering context at both
locations, with a collision policy that has the synthetic value win over any
event field literally named `rule_name`, matching the behaviour of the
notifier-level contexts.
Apply the same unflatten step to the throttle key renderer as the one added
in v1.2.0 for templates (issue #25), so dotted event fields like
`{{ nginx.http.status_code }}` resolve the same way in `throttle.key` as
they do in `title` / `body` / `email_body_html`.
Non-breaking. Existing configs that referenced `{{ rule_name }}` at the top
level continue to compile; they now produce the expected value instead of
an empty string. Configs that did not reference these variables render
identically to v1.2.0.
fix(templates): expose rule_name at layer 1 and in throttle key (#31)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or 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
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.
Promotes
release/1.2.1tomain. Patch release bundling the fix for #31 and a related consistency fix in the throttle key renderer.Bundled
{{ rule_name }}is now available in top-level templates (templates.<name>.title,body,email_body_html) and in thethrottle.keytemplate, not just in notifier-level templates. Synthetic wins over any event field literally namedrule_name.unflatten_dotted_keysstep that v1.2.0 added for template rendering ([Bug]: Error warning when fields contain dot characters, sample nginx.http.request_id #25) now also applies to the throttle key, so dotted event fields like{{ nginx.http.status_code }}resolve consistently inthrottle.key/title/body.docs/configuration.mdandconfig/config.example.yamlclarify which variables are available at each templating level.Validation
nginx.http.*keys). Both email and Telegram delivered the expected rendered content with{{ rule_name }}resolved. No 400 from Telegram, no empty-body fallback triggered.Non-breaking
Existing configs that referenced
{{ rule_name }}at layer 1 continue to compile; they now produce the rule name instead of an empty string. Configs that did not use these variables render byte-identically to v1.2.0.Release flow
After this merge,
v1.2.1gets tagged on the merge commit and the release build produces the final binaries and debs.