From 8c4926926cba65c061c4eb95e6f55f2972a35c31 Mon Sep 17 00:00:00 2001 From: deepunyk Date: Tue, 11 Aug 2026 20:59:47 +0530 Subject: [PATCH 1/4] feat: log the reason a request failed when errors are not fatal The step continues by default when a request fails, but nothing was written to the log, so a misconfigured token or an invalid payload gave no feedback at all. Warn with the reason instead, and point at the "errors" input for workflows that want the step to fail. Closes #502 --- .changeset/warn-failed-requests.md | 5 ++++ docs/additional-configurations.md | 2 ++ src/send.js | 3 +++ test/send.spec.js | 42 ++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 .changeset/warn-failed-requests.md diff --git a/.changeset/warn-failed-requests.md b/.changeset/warn-failed-requests.md new file mode 100644 index 00000000..783c98a6 --- /dev/null +++ b/.changeset/warn-failed-requests.md @@ -0,0 +1,5 @@ +--- +"@slack/slack-github-action": patch +--- + +feat: log a warning with the reason a request failed when the "errors" option is not set diff --git a/docs/additional-configurations.md b/docs/additional-configurations.md index 08045f4b..cd46e47a 100644 --- a/docs/additional-configurations.md +++ b/docs/additional-configurations.md @@ -8,6 +8,8 @@ Invalid API requests or unexpected webhook payloads cause a failing response tha The `errors` option defaults to `false` so failed requests do not cause the step to fail. This result can still be gathered from the `ok` output. +A step that continues after a failed request writes the reason for the failure, such as an `invalid_auth` error, to the step logs as a warning. Failures are logged as errors when the `errors` option is `true`. + ```yaml - name: Attempt to call an unknown method uses: slackapi/slack-github-action@v4.0.0 diff --git a/src/send.js b/src/send.js index 4127ce65..73ceeaf8 100644 --- a/src/send.js +++ b/src/send.js @@ -19,6 +19,9 @@ export default async function send(core) { core.setFailed(error); throw new SlackError(core, error); } + core.warning( + `Failed to send the request: ${error.message}. Set the "errors" input to "true" to fail this step for these errors.`, + ); } } diff --git a/test/send.spec.js b/test/send.spec.js index 157c3c96..c8d1b33f 100644 --- a/test/send.spec.js +++ b/test/send.spec.js @@ -1,5 +1,6 @@ import assert from "node:assert"; import { beforeEach, describe, it } from "node:test"; +import webapi from "@slack/web-api"; import send from "../src/send.js"; import { mocks } from "./index.spec.js"; @@ -75,4 +76,45 @@ describe("send", () => { assert.ok(mocks.core.setOutput.getCall(2).lastArg >= 0); }); }); + + describe("logging", async () => { + it("warns of the failed request when errors are not fatal", async () => { + mocks.core.getInput.withArgs("method").returns("chat.postMessage"); + mocks.core.getInput.withArgs("token").returns("xoxb-example"); + mocks.core.getInput.withArgs("payload").returns('"text": "hello"'); + mocks.calls.rejects( + new webapi.WebAPIPlatformError({ ok: false, error: "invalid_auth" }), + ); + await send(mocks.core); + assert.strictEqual(mocks.core.setFailed.called, false); + assert.equal(mocks.core.warning.getCalls().length, 1); + assert.match(mocks.core.warning.getCall(0).firstArg, /invalid_auth/); + }); + + it("warns of the failed webhook when errors are not fatal", async () => { + mocks.core.getInput + .withArgs("webhook") + .returns("https://hooks.slack.com"); + mocks.core.getInput.withArgs("webhook-type").returns("webhook-trigger"); + mocks.core.getInput.withArgs("payload").returns('"greetings": "hello"'); + mocks.webhook.trigger.rejects(new Error("invalid_payload")); + await send(mocks.core); + assert.strictEqual(mocks.core.setFailed.called, false); + assert.equal(mocks.core.warning.getCalls().length, 1); + assert.match(mocks.core.warning.getCall(0).firstArg, /invalid_payload/); + }); + + it("fails the step without warning when errors are fatal", async () => { + mocks.core.getBooleanInput.withArgs("errors").returns(true); + mocks.core.getInput.withArgs("method").returns("chat.postMessage"); + mocks.core.getInput.withArgs("token").returns("xoxb-example"); + mocks.core.getInput.withArgs("payload").returns('"text": "hello"'); + mocks.calls.rejects( + new webapi.WebAPIPlatformError({ ok: false, error: "invalid_auth" }), + ); + await assert.rejects(send(mocks.core)); + assert.ok(mocks.core.setFailed.called); + assert.strictEqual(mocks.core.warning.called, false); + }); + }); }); From 12b98ca1f76b234912efa60ef9c0e4380c563232 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Tue, 11 Aug 2026 14:57:02 -0700 Subject: [PATCH 2/4] docs: note logged warnings when errors are not fatal --- docs/additional-configurations.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/additional-configurations.md b/docs/additional-configurations.md index cd46e47a..bf7a1fbd 100644 --- a/docs/additional-configurations.md +++ b/docs/additional-configurations.md @@ -6,9 +6,7 @@ There are some additional, possibly useful, customization options for workflows. Invalid API requests or unexpected webhook payloads cause a failing response that can be used to fail the GitHub Actions step with the `errors` option. -The `errors` option defaults to `false` so failed requests do not cause the step to fail. This result can still be gathered from the `ok` output. - -A step that continues after a failed request writes the reason for the failure, such as an `invalid_auth` error, to the step logs as a warning. Failures are logged as errors when the `errors` option is `true`. +The `errors` option defaults to `false` so failed requests log a warning but don't cause the step to fail. The step's result can still be gathered from the `ok` output. ```yaml - name: Attempt to call an unknown method From 27d35e547bbc47193e74c68476e32fd6e4b536e3 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Tue, 11 Aug 2026 14:57:36 -0700 Subject: [PATCH 3/4] docs: remove recommendation to force errors to fail step from logged outputs --- src/send.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/send.js b/src/send.js index 73ceeaf8..9efc0803 100644 --- a/src/send.js +++ b/src/send.js @@ -19,9 +19,7 @@ export default async function send(core) { core.setFailed(error); throw new SlackError(core, error); } - core.warning( - `Failed to send the request: ${error.message}. Set the "errors" input to "true" to fail this step for these errors.`, - ); + core.warning(`Failed to send the request: ${error.message}`); } } From 5781fa3e86df999d2a6ac9bb82d9951907c21cd8 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Tue, 11 Aug 2026 15:03:23 -0700 Subject: [PATCH 4/4] docs: changeset versioning and wording of truth values Co-authored-by: Eden Zimbelman --- .changeset/warn-failed-requests.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/warn-failed-requests.md b/.changeset/warn-failed-requests.md index 783c98a6..81c80d0b 100644 --- a/.changeset/warn-failed-requests.md +++ b/.changeset/warn-failed-requests.md @@ -1,5 +1,5 @@ --- -"@slack/slack-github-action": patch +"@slack/slack-github-action": minor --- -feat: log a warning with the reason a request failed when the "errors" option is not set +feat: log a warning with the reason a request failed when the "errors" option is not true