diff --git a/x-pack/plugins/actions/server/builtin_action_types/slack.ts b/x-pack/plugins/actions/server/builtin_action_types/slack.ts index 042853796695d6..3a351853c1e462 100644 --- a/x-pack/plugins/actions/server/builtin_action_types/slack.ts +++ b/x-pack/plugins/actions/server/builtin_action_types/slack.ts @@ -35,7 +35,7 @@ const SecretsSchema = schema.object(secretsSchemaProps); export type ActionParamsType = TypeOf; const ParamsSchema = schema.object({ - message: schema.string(), + message: schema.string({ minLength: 1 }), }); // action type definition diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/slack.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/slack.ts index 5dcff8712a28d6..8afa43bfea21e6 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/slack.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/actions/builtin_action_types/slack.ts @@ -159,6 +159,20 @@ export default function slackTest({ getService }: FtrProviderContext) { expect(result.status).to.eql('ok'); }); + it('should handle an empty message error', async () => { + const { body: result } = await supertest + .post(`/api/action/${simulatedActionId}/_execute`) + .set('kbn-xsrf', 'foo') + .send({ + params: { + message: '', + }, + }) + .expect(200); + expect(result.status).to.eql('error'); + expect(result.message).to.match(/error validating action params: \[message\]: /); + }); + it('should handle a 40x slack error', async () => { const { body: result } = await supertest .post(`/api/action/${simulatedActionId}/_execute`)