From 83c2ce087366da4a8858d4bd61b6a04076e8721d Mon Sep 17 00:00:00 2001 From: githubdev58yashi <80401287+githubdev58yashi@users.noreply.github.com> Date: Fri, 21 Aug 2026 14:25:11 +0000 Subject: [PATCH 1/6] fix: proxy input always fails due to an undici version mismatch The ProxyAgent dispatcher is built with the npm "undici" package (v8), but was driven by globalThis.fetch, which Node bundles from a different (older) undici version. A breaking change to undici's request handler interface between v7 and v8 made every proxied request fail before any network I/O, regardless of whether the proxy or destination was reachable. Use undici's own exported fetch instead so the dispatcher and the fetch implementation always come from the same undici version. --- .../proxy-fetch-undici-version-mismatch.md | 5 +++++ src/proxies.js | 9 ++++++--- test/proxies.spec.js | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .changeset/proxy-fetch-undici-version-mismatch.md diff --git a/.changeset/proxy-fetch-undici-version-mismatch.md b/.changeset/proxy-fetch-undici-version-mismatch.md new file mode 100644 index 00000000..df5719ff --- /dev/null +++ b/.changeset/proxy-fetch-undici-version-mismatch.md @@ -0,0 +1,5 @@ +--- +"@slack/slack-github-action": patch +--- + +fix: proxy input always fails due to an undici version mismatch diff --git a/src/proxies.js b/src/proxies.js index d3b64e0e..5296dbbd 100644 --- a/src/proxies.js +++ b/src/proxies.js @@ -1,19 +1,22 @@ -import { ProxyAgent } from "undici"; +import { ProxyAgent, fetch as undiciFetch } from "undici"; import SlackError from "./errors.js"; /** * Return a fetch function that routes requests through a configured proxy. * + * Uses undici's own fetch, not the global fetch, since Node may bundle a + * different (incompatible) undici version for the latter. + * * @param {import("./config.js").default} config * @param {string?} [destination] - A provided request destination. - * @returns {typeof globalThis.fetch | undefined} + * @returns {typeof undiciFetch | undefined} */ export function fetch(config, destination) { const dispatcher = proxies(config, destination); if (!dispatcher) { return undefined; } - return (url, init) => globalThis.fetch(url, { ...init, dispatcher }); + return (url, init) => undiciFetch(url, { ...init, dispatcher }); } /** diff --git a/test/proxies.spec.js b/test/proxies.spec.js index f4ae9227..4d5c84bd 100644 --- a/test/proxies.spec.js +++ b/test/proxies.spec.js @@ -1,5 +1,6 @@ import assert from "node:assert"; import { beforeEach, describe, it } from "node:test"; +import { errors as undiciErrors } from "undici"; import Config from "../src/config.js"; import SlackError from "../src/errors.js"; import { fetch, proxies } from "../src/proxies.js"; @@ -20,6 +21,24 @@ describe("proxies", () => { assert.strictEqual(typeof fetchFn, "function"); }); + it("dispatches requests through the proxy without a request handler mismatch", async () => { + mocks.core.getInput.withArgs("method").returns("chat.postMessage"); + mocks.core.getInput.withArgs("token").returns("xoxb-example"); + mocks.core.getInput.withArgs("proxy").returns("http://127.0.0.1:1"); + const config = new Config(mocks.core); + const fetchFn = fetch(config); + await assert.rejects( + // ".invalid" is reserved by RFC 2606 to never resolve. + fetchFn("https://slack-github-action.invalid/api/chat.postMessage", { + method: "POST", + }), + (err) => { + assert.ok(!(err.cause instanceof undiciErrors.InvalidArgumentError)); + return true; + }, + ); + }); + it("returns undefined when no proxy is configured", async () => { mocks.core.getInput.withArgs("method").returns("chat.postMessage"); mocks.core.getInput.withArgs("token").returns("xoxb-example"); From 682abe0f974b501a6d801344c13674f3da79391f Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Wed, 18 Nov 2026 17:13:01 -0800 Subject: [PATCH 2/6] test: use node:test mocks for the proxy dispatch test Co-Authored-By: Claude --- test/proxies.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/proxies.spec.js b/test/proxies.spec.js index ccac4f12..f85ec41e 100644 --- a/test/proxies.spec.js +++ b/test/proxies.spec.js @@ -22,9 +22,10 @@ describe("proxies", () => { }); it("dispatches requests through the proxy without a request handler mismatch", async () => { - mocks.core.getInput.withArgs("method").returns("chat.postMessage"); - mocks.core.getInput.withArgs("token").returns("xoxb-example"); - mocks.core.getInput.withArgs("proxy").returns("http://127.0.0.1:1"); + mocks.inputs.set("method", "chat.postMessage"); + mocks.inputs.set("proxy", "http://127.0.0.1:1"); + mocks.inputs.set("token", "xoxb-example"); + mocks.fetch.mock.restore(); const config = new Config(mocks.core); const fetchFn = fetch(config); await assert.rejects( From 396e638b27773d7bf1949e8e25f77cfd1178e71e Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Thu, 19 Nov 2026 23:54:45 -0800 Subject: [PATCH 3/6] test: confirm form data uploads through the proxy as multipart bodies Co-Authored-By: Claude --- test/proxies.spec.js | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/proxies.spec.js b/test/proxies.spec.js index f85ec41e..b95b2ae6 100644 --- a/test/proxies.spec.js +++ b/test/proxies.spec.js @@ -1,4 +1,5 @@ import assert from "node:assert"; +import http from "node:http"; import { beforeEach, describe, it } from "node:test"; import { errors as undiciErrors } from "undici"; import Config from "../src/config.js"; @@ -40,6 +41,51 @@ describe("proxies", () => { ); }); + /** + * @see {@link https://github.com/slackapi/slack-github-action/pull/675} + */ + it("sends form data through the proxy as a multipart body", async () => { + const received = {}; + const server = http.createServer((req, res) => { + const chunks = []; + req.on("data", (chunk) => chunks.push(chunk)); + req.on("end", () => { + received.host = req.headers.host; + received.type = req.headers["content-type"]; + received.body = Buffer.concat(chunks).toString(); + res.end("{}"); + }); + }); + server.on("connect", (req, socket, head) => { + received.tunnel = req.url; + socket.write("HTTP/1.1 200 Connection Established\r\n\r\n"); + socket.unshift(head); + server.emit("connection", socket); + }); + await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); + mocks.inputs.set("method", "files.uploadV2"); + mocks.inputs.set("proxy", `http://127.0.0.1:${server.address().port}`); + mocks.inputs.set("token", "xoxb-example"); + mocks.fetch.mock.restore(); + mocks.fs.readFileSync.mock.restore(); + const config = new Config(mocks.core); + const fetchFn = fetch(config); + const body = new FormData(); + body.append("file", new Blob(["example"]), "example.txt"); + try { + await fetchFn("http://slack-github-action.invalid/upload", { + method: "POST", + body, + }); + } finally { + server.closeAllConnections(); + server.close(); + } + assert.strictEqual(received.host, "slack-github-action.invalid"); + assert.match(received.type, /^multipart\/form-data; boundary=/); + assert.match(received.body, /filename="example.txt"[\s\S]*example/); + }); + it("returns undefined when no proxy is configured", async () => { mocks.inputs.set("method", "chat.postMessage"); mocks.inputs.set("token", "xoxb-example"); From 63c8efb6c491a0c8ca8ceadbec0d21bb008a434b Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Thu, 19 Nov 2026 23:54:45 -0800 Subject: [PATCH 4/6] fix: use undici 7 to match the node 24 runtime for proxied requests Co-Authored-By: Claude --- .github/dependabot.yml | 3 +++ package-lock.json | 22 +++++++++++----------- package.json | 2 +- src/proxies.js | 9 +++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6188e456..598f1e8a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,6 +9,9 @@ updates: versions: - "25.x" - "26.x" + - dependency-name: "undici" + versions: + - "8.x" - package-ecosystem: "github-actions" directory: "/" schedule: diff --git a/package-lock.json b/package-lock.json index e1a40500..7c5e52b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "flat": "^6.0.1", "js-yaml": "^5.5.0", "markup-js": "^1.5.21", - "undici": "^8.12.3" + "undici": "^7.30.2" }, "devDependencies": { "@biomejs/biome": "^2.6.4", @@ -872,6 +872,12 @@ "undici-types": ">=7.24.0 <7.24.7" } }, + "node_modules/@types/node/node_modules/undici-types": { + "version": "7.30.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.30.2.tgz", + "integrity": "sha512-Vx15rZHtDo7X+sZVzcecz08ooRvEa0cjSs8z85v/jRRf81BT1m9eaoMI4gxvaNwgQg2IgkfjJ45dMpKrSl0zEQ==", + "license": "MIT" + }, "node_modules/@types/retry": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", @@ -1612,20 +1618,14 @@ } }, "node_modules/undici": { - "version": "8.12.3", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", - "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", + "version": "7.30.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.2.tgz", + "integrity": "sha512-mLyPQnHwUxaM/rideoK/+KL8DaAJLRl4aBCfmX444aCSLnIaomqPLtNRe2jdCYcsk5wZzXrDIQC8ZeYNRAYyIA==", "license": "MIT", "engines": { - "node": ">=22.19.0" + "node": ">=20.18.1" } }, - "node_modules/undici-types": { - "version": "8.12.3", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.12.3.tgz", - "integrity": "sha512-EXE4ydL3S76dFb27UFjNVZHTyv/TLdATj/KUe29ptdcg6qXL48J2tZ3126E5kICj5jn781OR+XlVH1N6Mz8jbA==", - "license": "MIT" - }, "node_modules/universal-user-agent": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz", diff --git a/package.json b/package.json index 480cfb89..5795202d 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "flat": "^6.0.1", "js-yaml": "^5.5.0", "markup-js": "^1.5.21", - "undici": "^8.12.3" + "undici": "^7.30.2" }, "overrides": { "undici-types": "$undici" diff --git a/src/proxies.js b/src/proxies.js index 5296dbbd..d3b64e0e 100644 --- a/src/proxies.js +++ b/src/proxies.js @@ -1,22 +1,19 @@ -import { ProxyAgent, fetch as undiciFetch } from "undici"; +import { ProxyAgent } from "undici"; import SlackError from "./errors.js"; /** * Return a fetch function that routes requests through a configured proxy. * - * Uses undici's own fetch, not the global fetch, since Node may bundle a - * different (incompatible) undici version for the latter. - * * @param {import("./config.js").default} config * @param {string?} [destination] - A provided request destination. - * @returns {typeof undiciFetch | undefined} + * @returns {typeof globalThis.fetch | undefined} */ export function fetch(config, destination) { const dispatcher = proxies(config, destination); if (!dispatcher) { return undefined; } - return (url, init) => undiciFetch(url, { ...init, dispatcher }); + return (url, init) => globalThis.fetch(url, { ...init, dispatcher }); } /** From c5a83d2dbfa6245a8d12009096d5185620b6223e Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 20 Nov 2026 00:48:34 -0800 Subject: [PATCH 5/6] chore: apply suggestions from code review Co-Authored-By: Claude --- .github/dependabot.yml | 2 +- test/proxies.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 598f1e8a..de55e88d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: versions: - "25.x" - "26.x" - - dependency-name: "undici" + - dependency-name: "undici" # https://undici.nodejs.org/#long-term-support versions: - "8.x" - package-ecosystem: "github-actions" diff --git a/test/proxies.spec.js b/test/proxies.spec.js index b95b2ae6..6fa5e946 100644 --- a/test/proxies.spec.js +++ b/test/proxies.spec.js @@ -22,7 +22,7 @@ describe("proxies", () => { assert.strictEqual(typeof fetchFn, "function"); }); - it("dispatches requests through the proxy without a request handler mismatch", async () => { + it("dispatches requests through the proxy with correct request handler", async () => { mocks.inputs.set("method", "chat.postMessage"); mocks.inputs.set("proxy", "http://127.0.0.1:1"); mocks.inputs.set("token", "xoxb-example"); From 23272600c0e4aaa3a04d8de65ffde7f7bcfd2413 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 20 Nov 2026 00:48:34 -0800 Subject: [PATCH 6/6] docs: describe the proxy fix in the changeset Co-Authored-By: Claude --- .changeset/proxy-fetch-undici-version-mismatch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/proxy-fetch-undici-version-mismatch.md b/.changeset/proxy-fetch-undici-version-mismatch.md index df5719ff..32ac79ce 100644 --- a/.changeset/proxy-fetch-undici-version-mismatch.md +++ b/.changeset/proxy-fetch-undici-version-mismatch.md @@ -2,4 +2,4 @@ "@slack/slack-github-action": patch --- -fix: proxy input always fails due to an undici version mismatch +fix: send requests through the configured proxy using the undici version that matches the node runtime