diff --git a/src/plugins/expressions/common/executor/executor.test.ts b/src/plugins/expressions/common/executor/executor.test.ts index 0a1e793ffbe22..75758dad783a0 100644 --- a/src/plugins/expressions/common/executor/executor.test.ts +++ b/src/plugins/expressions/common/executor/executor.test.ts @@ -197,6 +197,11 @@ describe('Executor', () => { types: ['string'], help: 'other arg', }, + nullable: { + types: ['string', 'null'], + help: 'nullable arg', + default: null, + }, }, extract: (state: ExpressionAstFunction['arguments']) => { const references: SavedObjectReference[] = [ @@ -254,6 +259,14 @@ describe('Executor', () => { expect(formatExpression(executor.inject(state, references))).toBe(expression); }); + + test('allows expression function argument to be null', () => { + const expression = `ref nullable=null id="my-id" other={ref id="nested-id" other="other" | foo bar="baz"}`; + const { state, references } = executor.extract(parseExpression(expression)); + + expect(state.chain[0].arguments.nullable[0]).toBeNull(); + expect(formatExpression(executor.inject(state, references))).toBe(expression); + }); }); describe('.getAllMigrations', () => { diff --git a/src/plugins/expressions/common/executor/executor.ts b/src/plugins/expressions/common/executor/executor.ts index 2767c8bc6ecbe..eb0e344b6dd60 100644 --- a/src/plugins/expressions/common/executor/executor.ts +++ b/src/plugins/expressions/common/executor/executor.ts @@ -204,7 +204,7 @@ export class Executor = Record { return asts.map((arg) => { - if (typeof arg === 'object') { + if (arg && typeof arg === 'object') { return this.walkAst(arg, action); } return arg;