Skip to content

fix(test): reject empty --filter before any requests - #660

Merged
zeshi-du merged 8 commits into
TestSprite:mainfrom
WUWTest:fix/empty-name-filter
Nov 10, 2026
Merged

zeshi-du merged 8 commits into
TestSprite:mainfrom
WUWTest:fix/empty-name-filter

Conversation

@WUWTest

@WUWTest WUWTest commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

An empty shell variable in --filter "$FILTER" currently runs every project test, or is silently ignored on a single-test invocation. Refuse an explicitly empty value in the test run, test rerun, and ci run actions before any request, including with --dry-run.

Use the existing VALIDATION_ERROR (exit 5, details.field: filter) and explain how to omit the flag or supply a non-empty substring. Omitted and non-empty values, including whitespace-only substrings, retain their behavior. Update all three help texts, their snapshots, and the command reference.

Related issue

Closes #606

Season 4 CLI Improvement Bonus

  • I'm entering this PR for the Season 4 CLI Improvement Bonus

Discord username:

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Documentation only
  • Build / CI / chore

Checklist

  • PR targets the main branch.
  • Commits follow Conventional Commits.
  • npm run lint and npm run format:check pass.
  • npm run typecheck passes.
  • npm test passes and coverage stays at or above the 80% gate.
  • New behavior is covered by unit tests (mock-based; no network or credentials required).
  • No secrets, API keys, internal endpoints, or personal data are included.
  • User-facing changes are reflected in DOCUMENTATION.md.

Notes for reviewers

The runtime change follows the accepted scope: one helper in test.ts, used by the three command actions; no selector refactor or new dependencies. The issue is assigned to WUWTest. Thanks to OkeyAmy for the report and reproducer.

The branch includes the upstream v0.16.0 release. The fix preserves its multiple-ID parsing and status filtering, and keeps the test rerun deprecation notice before validation. Only the original five contribution files differ from the updated main branch.

Validation on macOS, Node v25.9.0, against v0.16.0:

  • With the upstream runtime unchanged, all 21 empty-value regression cases fail; the 9 selection controls pass. With this fix, all 30 cases pass using injected HTTP fixtures.
  • Covers project, single-ID and multiple-ID paths, normal and dry-run modes, --filter=, and omitted/non-empty/whitespace-only controls.
  • Full unit suite with coverage: 4,943 passed, 2 skipped. Statements 90.22%, branches 85.31%, functions 83.85%, lines 92.36%.
  • Local E2E suite (including build and help snapshots): 110 passed, 1 skipped.
  • Typecheck, lint, format check and git diff --check pass. Production dependency audit reports 0 vulnerabilities. Exactly three help snapshots differ from main.
  • The final remote tree was fetched and matched byte-for-byte to the locally validated tree. Hosted CI for this updated head is pending maintainer approval.

Summary by CodeRabbit

  • Bug Fixes
    • test run, test rerun, and ci run now reject an explicitly empty --filter with a validation error before making a request, including in dry-run and single-test cases.
    • Non-empty filters match case-insensitive substrings, and whitespace is preserved. Omitting the filter selects all project tests.
  • Documentation
    • Updated command help and documentation to clarify filter behavior, including that specified filters must be non-empty.

Document empty --filter validation and unchanged omitted/non-empty behavior for test run, test rerun, and ci run.
Validate --filter in the test run, test rerun, and ci run actions with the existing exit-5 validation error. Preserve omitted and non-empty values, including whitespace, and cover the command paths with offline regression tests.

Refs TestSprite#606
Update only test run, test rerun, and ci run help snapshots to match the clarified --filter option.
@github-actions

Copy link
Copy Markdown

🏆 Season 4 CLI Improvement Bonus: entry recorded. Thanks, @WUWTest!

To be counted, this PR needs the following by Oct 29, 11:59 PM PT:

  • ✅ A linked issue assigned to you.
  • ✅ Out of draft.
  • ℹ️ No Discord username in the description. Add one so we can reach you, or we'll reach you here on the PR.

Rewards go to merged PRs judged a genuine improvement, and up to three bonus-eligible PRs count per person. Untick the box to withdraw the entry. This comment refreshes when you edit the PR. Full rules.

@github-actions github-actions Bot added the s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus label Oct 24, 2026
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The test run, test rerun, and CI commands now reject explicitly empty --filter values before making a request. Omitted filters, non-empty filters, and whitespace-only values retain their existing meanings.

Changes

Name Filter Validation

Layer / File(s) Summary
Validate test and CI command filters
src/commands/test.ts, src/commands/ci.ts
parseNameFilter rejects an empty value. The test run, test rerun, and CI handlers pass the parsed filter to their existing execution paths. Help text describes the non-empty filter rule.
Test filter validation and selection
src/commands/test.filter.spec.ts
Tests cover rejection before requests, omitted filters, case-insensitive matching, and preserved whitespace for test and CI commands.
Document filter behavior
DOCUMENTATION.md
Documentation describes empty-filter errors, case-insensitive matching, and preserved whitespace for test run, test rerun, and ci run.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Merge Risk: Low · up to 9f140

Some invalid empty-filter invocations can still make background requests. Gate those requests to meet the documented validation guarantee.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(test): reject empty --filter before any requests" matches the main change. The raw summary and objectives show that an explicitly empty --filter now fails with VALIDATION_ERROR (exit 5)…
Linked Issues check Passed Issue #606 is the only active direct link. Its coding requirements are: (1) refuse an explicitly empty --filter before any request in test run, test rerun, and ci run, including single-test, `…
Out of Scope Changes check Passed All changed files map to #606 or to its required validation:
- src/commands/test.ts: parseNameFilter and its use in the test run and test rerun handlers. This is the required validation and he…
Full details: Title check

Explanation

The title "fix(test): reject empty --filter before any requests" matches the main change. The raw summary and objectives show that an explicitly empty --filter now fails with VALIDATION_ERROR (exit 5) before any request in test run, test rerun, and ci run, including dry-run. The title is specific, short, and uses a conventional commit prefix. It does not cover the help text or documentation updates, which is expected.

Full details: Linked Issues check

Explanation

Issue #606 is the only active direct link. Its coding requirements are: (1) refuse an explicitly empty --filter before any request in test run, test rerun, and ci run, including single-test, --all, and --dry-run paths; (2) return VALIDATION_ERROR, exit 5, details.field: filter, with guidance to omit the flag or pass a non-empty substring; (3) keep omitted and non-empty filters unchanged, including whitespace-only values; (4) update the --filter help text and DOCUMENTATION.md for the three commands; (5) add automated regression tests.

Evidence in the whole-PR summary (merge base 4b5ae55 to head ccb1c71):

  • src/commands/test.ts adds and exports parseNameFilter. It throws a local validation error for '' and returns undefined or the original non-empty string. The test run and test rerun handlers call it before passing the result to their run functions. This covers single-test and --all paths.
  • src/commands/ci.ts routes ci run --filter through parseNameFilter before assigning nameFilter.
  • src/commands/test.filter.spec.ts adds mocked-request tests. They cover empty-value rejection with exit 5, omitted filters selecting every test, a non-empty case-insensitive match (aLPHa), and whitespace-only values that are not trimmed.
  • Help text in test.ts and ci.ts states that the value must be non-empty and that omitting the flag selects every test. DOCUMENTATION.md makes the same statement for the three commands.

The PR description reports 30 regression cases that pass, including dry-run paths, and reports that the upstream runtime fails 21 of them. The summary shows the dry-run assertion for only the first empty spelling tested. The helper runs before the dry-run branch, so the dry-run behavior follows from the code path. The ignored help snapshot file is not reviewed. The snapshot is a derived test artifact, not a coding requirement of #606, so it does not affect this verdict. The PR objectives cite different test counts (24 cases; 4,822 unit tests). The current PR description supersedes those figures and they do not change any requirement.

Full details: Out of Scope Changes check

Explanation

All changed files map to #606 or to its required validation:

  • src/commands/test.ts: parseNameFilter and its use in the test run and test rerun handlers. This is the required validation and help text.
  • src/commands/ci.ts: the same validation for ci run, the option description, and a comment on createCiCommand. The comment explains the implemented behavior and does not change runtime behavior.
  • src/commands/test.filter.spec.ts: regression tests for the three commands. They cover the required rejection cases and the required controls (omitted, non-empty, whitespace-only).
  • DOCUMENTATION.md: updates required by #606.
  • test/__snapshots__/help.snapshot.test.ts.snap (excluded from review): updates the help snapshots for the changed help text. This follows from the required help-text change.

The summary shows no selector refactor, no new dependency, no change to read-only list commands, and no change to --status behavior from #498. The PR description states that package.json and package-lock.json are unchanged, so the dependency audit failure is not caused by this PR. No unrelated change is shown in the reviewed evidence.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Add the missing docstring for the command factory touched by the filter fix, following the review coverage advisory. No runtime behavior changes.
@WUWTest

WUWTest commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Hosted CI and coverage have now run for 66e662e and both pass: CI (including Node 20/22/24, Windows unit tests, and macOS smoke) and coverage.

The remaining Dependency Audit failure reports the existing undici@7.29.1 production dependency. package.json, package-lock.json, and the audit workflow are byte-for-byte identical to base a18d37c. The dependency update is already tracked in #674 and #678. Docs PR #644 has the same audit failure with passing CI and coverage.

This PR retains the accepted scope of #606; it includes no dependency changes.

Cover the v0.16.0 multiple-ID paths in test run and test rerun. The existing matrix now checks that empty --filter and --filter= values fail before requests in both normal and dry-run modes.

Refs TestSprite#606

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1
src/commands/test.ts-15235-15235: 1

15235-15235: Minor · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Validate an empty filter before the list shortcut.

If a caller runs test run list --filter "", the earlier list check throws with details.field: test-id. Move parseNameFilter(cmdOpts.filter) before that check so an explicitly empty filter always produces details.field: filter. Add this input to the regression cases.

As per path instructions, focus on “Correctness and clear error handling.”

Source: Path instructions


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between dc0f8f8 and ccb1c71.

Files ignored due to path filters: 1
  • test/__snapshots__/help.snapshot.test.ts.snap is excluded by !**/*.snap, !**/*.snap
Files selected for processing: 3
  • DOCUMENTATION.md
  • src/commands/test.filter.spec.ts
  • src/commands/test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@WUWTest

WUWTest commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Checked the unverified test run list --filter "" suggestion from the latest review with injected fetch fixtures. All 8 probes returned VALIDATION_ERROR / exit 5 with zero requests, including the dry-run and --filter= spellings.

The upstream v0.16.0 test run list typo guard explicitly takes precedence over other validation and points to test result <test-id> --history. It treats the literal list as a mistaken subcommand. I have retained that existing ordering. Normal single-ID and multiple-ID paths with an empty filter still report details.field: filter before requests; the project paths are covered by the 30-case regression suite.

@zeshi-du
zeshi-du merged commit 396f925 into TestSprite:main Nov 10, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s4-cli-bonus Entered for the Season 4 CLI Improvement Bonus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Hackathon] fix(test): --filter "" silently widens test run --all, test rerun --all, and ci run to every test

2 participants