From 38915583c9363ab9b9dddb8ecd008f8ad144a8ad Mon Sep 17 00:00:00 2001 From: workers-sdk factory Date: Fri, 13 Nov 2026 17:39:18 +0000 Subject: [PATCH] test: wrangler deploy gives no warning when _redirects exceeds the dynamic-rule limit (#14694) Deploying a _redirects file with more than 100 dynamic rules, including exact-path rules counted as dynamic after a splat, drops the rest of the file (and any trailing catch-all) with no warning from wrangler deploy. --- .../src/__tests__/deploy/assets.test.ts | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/packages/wrangler/src/__tests__/deploy/assets.test.ts b/packages/wrangler/src/__tests__/deploy/assets.test.ts index f90b232621..6196f719e7 100644 --- a/packages/wrangler/src/__tests__/deploy/assets.test.ts +++ b/packages/wrangler/src/__tests__/deploy/assets.test.ts @@ -927,6 +927,77 @@ describe("deploy", () => { `); }); + it("should warn when _redirects has more dynamic rules than the limit", async ({ + expect, + }) => { + // 150 dynamic rules: the last 50 are dropped by the 100 dynamic-rule limit + const redirectsContent = Array.from( + { length: 150 }, + (_, i) => `/a/${i}/* /b/${i}/:splat` + ).join("\n"); + const assets = [ + { filePath: "_redirects", content: redirectsContent }, + { filePath: "index.html", content: "" }, + ]; + writeAssets(assets); + writeWranglerConfig({ + assets: { directory: "assets" }, + }); + const bodies: AssetManifest[] = []; + await mockAUSRequest(bodies); + mockSubDomainRequest(); + mockUploadWorkerRequest({ + expectedAssets: { + jwt: "<>", + config: { + _redirects: redirectsContent, + }, + }, + expectedType: "none", + }); + await runWrangler("deploy"); + expect(std.warn).toContain( + "Maximum number of dynamic rules supported is 100" + ); + }); + + it("should warn when exact-path rules after a splat push _redirects over the dynamic-rule limit", async ({ + expect, + }) => { + // Every rule after the first splat counts as dynamic, so the rules past + // the 100th, including the trailing catch-all, are dropped + const redirectsContent = [ + "/blog/* /posts/:splat 301", + ...Array.from({ length: 150 }, (_, i) => `/old/${i} /new/${i} 301`), + "/* /404.html 404", + ].join("\n"); + const assets = [ + { filePath: "_redirects", content: redirectsContent }, + { filePath: "index.html", content: "" }, + { filePath: "404.html", content: "Not found" }, + ]; + writeAssets(assets); + writeWranglerConfig({ + assets: { directory: "assets" }, + }); + const bodies: AssetManifest[] = []; + await mockAUSRequest(bodies); + mockSubDomainRequest(); + mockUploadWorkerRequest({ + expectedAssets: { + jwt: "<>", + config: { + _redirects: redirectsContent, + }, + }, + expectedType: "none", + }); + await runWrangler("deploy"); + expect(std.warn).toContain( + "Maximum number of dynamic rules supported is 100" + ); + }); + it("should resolve assets directory relative to cwd if using cli", async ({ expect, }) => {