test(build): guard the artifact path policy arrays against duplicates (#12422)

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.
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-09-02 10:22:03 -03:00
committed by GitHub
parent 5ab1e9fe5c
commit 451d4cd93c

View File

@@ -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"),