From 451d4cd93cebe935f504259e8879e0bbed2020a2 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Wed, 2 Sep 2026 10:22:03 -0300 Subject: [PATCH] test(build): guard the artifact path policy arrays against duplicates (#12422) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reduced on merge rather than closed, because the useful half is not subsumed. The production change is: #12423 landed first and reached the same end state for scripts/build/pack-artifact-policy.ts — one volatileEnvPath.mjs entry, keeping the #11437 comment that explains why it is REQUIRED (bin/omniroute.mjs calls describeVolatileEnvWarning on every CLI boot, and bin/cli/ is only an allowlist prefix, so its absence would otherwise be silent). This PR's base carried three occurrences and reduced them to one; the tip is already there, so that file takes the tip's side. What survives is the guard test, which does not exist on the tip: it asserts the four artifact path policy arrays contain no duplicate entries, so the class of defect cannot come back quietly. Verified by proof rather than assumption — re-introducing the duplicate makes it fail, removing it makes it pass again. Verified: 18/18 in pack-artifact-policy after the reduction. Thanks — the duplicate was real and the guard is the part worth keeping. --- tests/unit/pack-artifact-policy.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/pack-artifact-policy.test.ts b/tests/unit/pack-artifact-policy.test.ts index aeea454fad..46f3b42f50 100644 --- a/tests/unit/pack-artifact-policy.test.ts +++ b/tests/unit/pack-artifact-policy.test.ts @@ -15,6 +15,21 @@ import { parseJsonValuesOutput, } from "../../scripts/build/pack-artifact-policy.ts"; +test("artifact path policy arrays contain no duplicate entries", () => { + const policies = { + APP_STAGING_ALLOWED_EXACT_PATHS, + APP_STAGING_ALLOWED_PATH_PREFIXES, + PACK_ARTIFACT_ALLOWED_EXACT_PATHS, + PACK_ARTIFACT_ALLOWED_PATH_PREFIXES, + PACK_ARTIFACT_REQUIRED_PATHS, + }; + + for (const [name, paths] of Object.entries(policies)) { + const duplicates = [...new Set(paths.filter((entry, index) => paths.indexOf(entry) !== index))]; + assert.deepEqual(duplicates, [], `${name} contains duplicate paths: ${duplicates.join(", ")}`); + } +}); + test("normalizeArtifactPath normalizes slashes and leading relative markers", () => { assert.equal( normalizeArtifactPath("./app\\scripts\\ad-hoc\\test.js"),