From 36d6590d2daefc97626ca68dab61831808fbd4d3 Mon Sep 17 00:00:00 2001 From: CJ Cenizal Date: Fri, 13 Mar 2020 18:23:18 -0700 Subject: [PATCH] Handle improperly defined Watcher Logging Action text parameter. (#60169) --- .../application/models/action/logging_action.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/watcher/public/application/models/action/logging_action.js b/x-pack/plugins/watcher/public/application/models/action/logging_action.js index bef094b57cc8..1590ee62e68b 100644 --- a/x-pack/plugins/watcher/public/application/models/action/logging_action.js +++ b/x-pack/plugins/watcher/public/application/models/action/logging_action.js @@ -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,