Handle improperly defined Watcher Logging Action text parameter. (#60169) (#60188)

This commit is contained in:
CJ Cenizal 2020-03-13 20:20:48 -07:00 committed by GitHub
parent 050b629f29
commit 1cf7368761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,7 +37,18 @@ export class LoggingAction extends BaseAction {
get upstreamJson() {
const result = super.upstreamJson;
const text = !!this.text.trim() ? this.text : undefined;
let text;
if (typeof this.text === 'string') {
// If this.text is a non-empty string, we can send it to the API.
if (!!this.text.trim()) {
text = this.text;
}
} else {
// If the user incorrectly defined this.text, e.g. as an object in a JSON watch, let the API
// deal with it.
text = this.text;
}
Object.assign(result, {
text,