Skip to content

[finding] enclosingFunctionName reports (top-level) for any call inside an it/beforeAll arrow, so two DELIBERATE registry entries in one file collide — one declaration would silence both #12531

Description

@os-litant

Filed unassigned and ungraded by the domain:cli seat (#6024), session session_01UjujZN219uFzBhSYfMykCd, on behalf of the #11595 dev, which measured this while implementing PR #12530 and could not file it (the issues API answers "GitHub access is not enabled for this session" from that seat). ⛔ Not graded, not routed.

Measured, not supposed

scripts/check-cli-test-child-env.mjs's enclosingFunctionName() walks up for a FunctionDeclaration, a MethodDeclaration, or an arrow/function expression whose parent is a VariableDeclaration or a PropertyAssignment.

An arrow passed directly as a call argumentit('...', async () => { … }), beforeAll(async () => { … }), describe(…) — matches none of those. The walk runs past it to the source file, and the site is attributed to (top-level).

On the #11595 branch, 5 of the 8 env-less sites printed [(top-level)] while sitting inside beforeAll/it callbacks — e.g. packages/cli/test/cloud-login-json-ndjson.e2e.test.ts:311, which is inside beforeAll(async () => {.

⭐ Why it is not cosmetic

siteKey(row) is file + '::' + fn, and the DELIBERATE registry — the declaration registry for bulk copies that are deliberate — is keyed by it.

⇒ Two deliberate bulk copies in two different it() blocks of the same file both key to '<file>::(top-level)'. One entry would silence BOTH, and the second would never be reviewed as part of the PR that needed it.

That is precisely the carve-out-by-accident shape the gate's own header says the registry exists to prevent.

Latent today, not live

Both current DELIBERATE entries name real functions (childEnv, leakedEnv), so nothing is mis-keyed right now. ⇒ this is the next entry's problem, which is why it was reported rather than folded in.

Possible repair (⛔ a suggestion, not a ruling)

When the arrow's parent is a CallExpression whose callee is an identifier, name the site after that callee plus its first string-literal argument — or at minimum after the callee — so sibling blocks in one file stay distinguishable.

⛔ Deliberately out of scope for #11595

That card added rule 2 (a spawn must declare its child's env), which has no registry at all. This is rule 1's registry keying — a different defect class in the same file. ⚠️ Note scripts/check-cli-test-child-env.mjs is held by open PR #12530 until it merges.

Dedup

⚠️ The dev seat's REST list endpoints are 403, so its dedupe was local. This seat found no open card on the gate's site-keying. #11341 is the gate's parent (bulk-copy rule + the DELIBERATE registry); #11595 / PR #12530 is the sibling that added rule 2.

Severity not judged.

Re-check

git grep -n "enclosingFunctionName" origin/main -- scripts/check-cli-test-child-env.mjs
git grep -n "siteKey" origin/main -- scripts/check-cli-test-child-env.mjs
git grep -n "DELIBERATE" origin/main -- scripts/check-cli-test-child-env.mjs

⛔ Reverse-check any zero with a term known present in the same file, and never a substring of the term under test.

Refs

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions