Skip to content

fix(tasks): reject invalid CLI filter values - #124520

Merged
steipete merged 1 commit into
mainfrom
steipete/tasks-filter-validation
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/tasks-filter-validation

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where closed-set CLI filters silently accepted invalid values and reported empty task, TaskFlow, audit, or model results. In human mode this could confidently tell an operator that no tasks or models existed after a typo.

The same sweep found browser console --level: unknown values were accepted, and the documented warn value was treated as info because the collector only recognized warning.

Why This Change Was Made

Task runtimes/statuses now come from canonical tuples in the task registry domain, with a distinct TaskFlow status tuple because flows genuinely own waiting and blocked. Task and TaskFlow audit codes remain producer-owned and feed one de-duplicated system-audit vocabulary. Both Commander handlers and the route-first JSON task path validate before reading registry state, while help text is generated from those same owners.

models list --provider remains dynamic: after config, manifest metadata, and configured entries are loaded, it canonicalizes the requested id and checks it against the already-loaded installed/configured provider inventory before any model registry/catalog discovery. A known provider with no rows remains a successful empty result.

User Impact

Invalid task, TaskFlow, audit, model-provider, and browser-console filters now name the accepted values or recovery command and exit non-zero. Lowercase task enums remain exact-match, matching the existing audit and Commander enum behavior; RUNNING is rejected rather than silently normalized.

Successful JSON shapes are unchanged. Valid filters that match no rows still exit 0, and valid filters with rows still return them.

Evidence

Before, each reported value exited 0 with an empty result. After the isolated built-artifact run:

Command/filter After
tasks list --status bogus --json valid task statuses, exit 1
tasks list --status RUNNING --json valid task statuses, exit 1
tasks list --runtime bogus --json valid runtimes, exit 1
tasks flow list --status bogus --json valid TaskFlow statuses, exit 1
tasks audit --severity bogus warn or error, exit 1
tasks audit --code bogus-code valid audit codes, exit 1
models list --provider bogus --json unknown-provider recovery guidance, exit 1
browser console --level bogus --json error, warn, or info, exit 1

Must-not-break proof in the same isolated state:

  • tasks list --status running --json -> unchanged empty task payload, exit 0.
  • configured empty-provider with models: [], then models list --provider empty-provider --json -> { "count": 0, "models": [] }, exit 0.
  • models list --provider openai --json -> one model row, exit 0.
  • Human invalid task/model filters print only the actionable error; neither prints No background tasks found or No models found.

Validation:

  • Pre-fix regression proof: task list/audit, routed task JSON, TaskFlow, provider, and browser cases failed because the query/dispatch happened first; documented browser warn also included info rows.
  • Focused Vitest: task commands + routed JSON, TaskFlow commands, model list unit/E2E, CLI registration/cold imports, and browser CLI/activity suites.
  • node scripts/check-changed.mjs on Blacksmith Testbox tbx_01m04rfn0dzc5n2mkdey4cs74r: clean.
  • pnpm build on the same Testbox: clean.
  • Isolated built CLI: OPENCLAW_STATE_DIR=$(mktemp -d), OPENCLAW_SKIP_CHANNELS=1, direct dist/entry.js; no live operator state or Gateway port used.
  • Autoreview: clean, no accepted/actionable findings.
  • LOC: production +241/-153 (net +88); tests +308/-28 (net +280). Production growth is the shared CLI validation boundary, lightweight canonical audit/type owners, dynamic provider-inventory distinction, and the bounded browser sweep fix; duplicated help/type lists and stale exports were removed.

AI-assisted: yes. The implementation and evidence above were inspected and verified.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations extensions: browser size: L maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 09:01
@steipete
steipete merged commit 77902b1 into main Aug 16, 2026
253 checks passed
@steipete
steipete deleted the steipete/tasks-filter-validation branch August 16, 2026 09:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations extensions: browser maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant