Skip to content

fix(scripts): the harness arg parser refuses its last three silent-input paths (TASK-080) - #1776

Merged
lilyshen0722 merged 1 commit into
mainfrom
kai/harness-arg-silence
Sep 19, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
kai/harness-arg-silence

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Follow-up to #1775, from Vera's review of the cleared head (70134) plus a third of the same class I measured. She classified the first two as a follow-up rather than a hold, so 1f256eb3 was not churned; the module only exists on main after #1775, which is why this cuts from 08ddfd22.

The class

Every one of these is an input the parser accepted and then did something other than what was asked. That is the defect rule 27 names, in the module written to refuse it.

1. A value containing = was cut at the second one. --route=/v2/x?tab=a ran as /v2/x?tab, and worse with two query params: --route=/v2/x?a=1&b=2 ran as /v2/x?a (measured both). The capture is of a different page, under a file name that names the right one — the exact failure mode the viewport/auth run line exists to expose. Cause: arg.slice(2).split('=') destructured, which drops everything past the second separator. Repair: split at the first = (indexOf), so a value may contain =.

2. A repeated flag kept only its last value. --width 390 --width 900 → 900, silently, in either spelling of the same flag. Repair: refuse a repeated flag and name it. The first value was already accepted and the second contradicts it, so neither is trustworthy, and last-wins is a decision the caller did not make.

3. A flag given an empty value was treated as absent. --selector= sets '', which is falsy, so the script silently took the full-page path while the caller believed the capture was scoped. This is the shape an unset shell variable takes (--selector= "$SEL"), which is why it is worth refusing rather than defaulting. --route/--out were already safe through their own falsy check; the other flags were not. Repair: refuse any --flag= with an empty value.

An unknown flag given an empty value (--widht=) is reported as both unknown and empty, which is why the key is recorded in values as well as in the empty list.

Evidence

  • backend/__tests__/unit/scripts/uiEvidenceShotArgs.test.js — 11 tests, all passing; the script test directory as a whole is 16 suites / 114 tests green.
  • End-to-end against the real script, each exiting 2 with no browser needed (validation precedes the Playwright import): --route=/v2/x?a=1&b=2 … --width 390 --width 900 → repeated flag(s): --width …; --selector= → empty value(s): --selector= …; --width 390 400 (the earlier repair) → unexpected value(s): 400 ….
  • Four mutations, each reddening its own witness:
    • cut the inline value at its next = → the toEqual on the route value;
    • stop recording repeats → the repeated-flag test;
    • stop treating --flag= as empty → the empty-value test's first assertion (test-file line 99);
    • stop recording the empty key in values → the same test's second assertion (line 102), the unknown-flag half — while the empty half at line 103 still passes, which is exactly what recording the key in both buckets buys.

Scope

scripts/lib/ui-evidence-args.js, scripts/ui-evidence-shot.mjs (unchanged — it already passes the whole parse result to refusalFor), docs/runbooks/local-ui-render-harness.md, one backend test. No version slot: scripts/, docs/ and backend/__tests__ are outside what the release ladder guards, same as #1775.

…put paths (TASK-080)

All three are inputs the parser accepted and then did something other than what
was asked — the class review-checklist rule 27 names, in the module written to
refuse it:

- a value containing `=` was cut at the SECOND one, so
  `--route=/v2/x?a=1&b=2` ran as `/v2/x?a` and captured a different page under a
  file name that named the right one;
- a repeated flag kept only its last value, silently, in either spelling
  (`--width 390 --width 900` and `--width 390 --width=900`);
- a flag given an empty value (`--selector=`, the shape an unset shell variable
  takes) was treated as the flag being absent, so `--selector= "$SEL"` captured
  the full page while the caller believed the capture was scoped.

`parseArgs` now splits at the first `=`, records repeated flags and empty values,
and `refusalFor` reports them alongside the existing unknown-flag and stray-value
refusals. An unknown flag given an empty value (`--widht=`) is reported as both,
which is why the key is recorded in `values` as well as in the empty list.

Three tests, and four mutations each reddening its own witness.
@lilyshen0722
lilyshen0722 merged commit 0359726 into main Sep 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant