-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Watcher: Validate email adresses when storing a watch #34042
Watcher: Validate email adresses when storing a watch #34042
Conversation
Right now, watches fail on runtime, when invalid email addresses are used. All those fields can be checked on parsing, if no mustache is used in any email address template. In that case we can return immediate feedback, that invalid email addresses should not be specified when trying to store a watch.
Pinging @elastic/es-core-infra |
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.
Big +1 for validation. Small nits on the way we evaluate using mustache, would love your thoughts.
|
||
public TextTemplate(String template) { | ||
this.script = null; | ||
this.inlineTemplate = template; | ||
this.isUsingMustache = template.contains("{{") && template.indexOf("{{") < template.indexOf("}}"); |
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.
sneak attack bring back the validation
this.inlineTemplate = null; | ||
} | ||
|
||
public TextTemplate(Script script) { | ||
this.script = script; | ||
this.inlineTemplate = null; | ||
this.isUsingMustache = script.getIdOrCode().contains("{{") && |
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.
can we lazy load this in the getter? maybe remove the word get
so we know it "mutates state" and load it once only if we decide to actually validate if we care or not. At least it will appease the contains
'ing every string is bad gods.
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.
I changed this only to check for {{
, and it #33978 will introduce a check for every text template, so that this will be called anyway...
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.
oof, how did i miss that? I guess going backwards thru my review-requested emails is not such a good idea!!
still lgtm |
Right now, watches fail on runtime, when invalid email addresses are used. All those fields can be checked on parsing, if no mustache is used in any email address template. In that case we can return immediate feedback, that invalid email addresses should not be specified when trying to store a watch.
Right now, watches fail on runtime, when invalid email addresses are
used.
All those fields can be checked on parsing, if no mustache is used in
any email address template. In that case we can return immediate
feedback, that invalid email addresses should not be specified when
trying to store a watch.
Reviewers note: This is rather for discussion than for review. Do you think this makes sense despite the additional check if mustache templates are used or not? When mustache is used, than this can still fail on runtime - even though the majority of the cases that I have seen are indeed using static email addresses when defining a watch.
Closes #33980