Skip to content

fix(cli): reject invalid search limit values - #84480

Closed
jbetala7 wants to merge 2 commits into
openclaw:mainfrom
jbetala7:fix/84473-search-limit-parser
Closed

jbetala7 wants to merge 2 commits into
openclaw:mainfrom
jbetala7:fix/84473-search-limit-parser

Conversation

@jbetala7

@jbetala7 jbetala7 commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • reject malformed --limit values for plugins search and skills search
  • keep the strict positive-integer option adapter in a Commander-only CLI module so src/cli/program/helpers.ts remains free of runtime Commander imports
  • cover invalid and valid limit parsing through the plugins and skills command paths

Fixes #84473.

Real behavior proof

  • Behavior or issue addressed: plugins search --limit and skills search --limit no longer accept partially numeric values such as 1abc; invalid values fail during CLI option parsing before ClawHub calls, while strict positive integers such as +1 are still accepted.
  • Real environment tested: Local OpenClaw source checkout on macOS, branch fix/84473-search-limit-parser, commit 80c08226f0d96f9d7436da20822cdf6354c6983d, Node v24.11.1.
  • Exact steps or command run after this patch: Ran the source-entry CLI parser directly with invalid and valid plugin/skill search limits.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): Copied terminal output from the local source checkout:
$ node --import tsx src/entry.ts plugins search calendar --limit 1abc --json
OpenClaw could not parse this command: option '--limit <n>' argument '1abc' is invalid. Expected a positive integer.
Try: openclaw plugins search --help
exit=1

$ node --import tsx src/entry.ts skills search calendar --limit 1abc --json
OpenClaw could not parse this command: option '--limit <n>' argument '1abc' is invalid. Expected a positive integer.
Try: openclaw skills search --help
exit=1

$ node --import tsx src/entry.ts plugins search calendar --limit +1 --json
{
  "results": []
}
exit=0

$ node --import tsx src/entry.ts skills search calendar --limit +1 --json
{
  "results": [
    {
      "score": 4.397586954646213,
      "slug": "calendar",
      "displayName": "Calendar",
      "summary": "Calendar management and scheduling. Create events, manage meetings, and sync across calendar providers.",
      "version": null,
      "ownerHandle": "ndcccccc"
    }
  ]
}
exit=0
  • Observed result after fix: Both invalid 1abc commands exited 1 with Commander parse errors before reaching the search action. Both valid +1 commands exited 0 and executed the real source-entry search path.
  • What was not tested: Browser, gateway UI, and private credential paths were not tested because this bug is limited to source-entry CLI option parsing for public plugins and skills search commands.
  • Proof limitations or environment constraints: Plugin search returned an empty public result set for calendar, while skills search returned one public ClawHub result; both commands still prove that +1 is accepted and the command action runs.
  • Before evidence (optional but encouraged): Current upstream main still parses both search limits with Number.parseInt(value, 10), which accepts partially numeric values such as 1abc as 1.

Validation

  • node scripts/run-vitest.mjs src/cli/program/helpers.test.ts src/cli/plugins-cli.lazy.test.ts src/cli/skills-cli.commands.test.ts (3 files, 72 tests passed)
  • ./node_modules/.bin/oxfmt --check --threads=1 src/cli/program/helpers.ts src/cli/positive-integer-option.ts src/cli/plugins-cli.ts src/cli/skills-cli.ts src/cli/program/helpers.test.ts src/cli/plugins-cli.lazy.test.ts src/cli/skills-cli.commands.test.ts
  • git diff --check

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 26, 2026, 3:15 PM ET / 19:15 UTC.

Summary
This PR replaces parseInt-based --limit parsing in plugins search and skills search with a Commander-scoped strict positive-integer parser and adds command-path tests for invalid and signed valid values.

PR surface: Source +12, Tests +73. Total +85 across 5 files.

Reproducibility: yes. Source inspection on current main shows both affected search commands still use Number.parseInt(value, 10), and the PR body supplies before/after source-entry CLI output for the invalid and valid paths.

Review metrics: 1 noteworthy metric.

  • CLI option parsers changed: 2 changed. Both ClawHub search commands now fail fast on invalid --limit values, which is the compatibility-sensitive part maintainers should notice before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • Merging this changes malformed or non-positive plugins search --limit and skills search --limit values from being coerced, clamped, or defaulted later to failing during Commander parsing, so scripts that accidentally relied on lenient parsing will stop with an option error.

Maintainer options:

  1. Accept strict search-limit parsing (recommended)
    Merge if maintainers agree malformed and non-positive search limits should fail during Commander parsing instead of being coerced or clamped later.
  2. Preserve lenient behavior
    If compatibility with malformed existing invocations matters, ask for a different design that keeps the current default behavior and introduces any stricter behavior separately.

Next step before merge
No ClawSweeper repair is needed because there are no blocking code findings; maintainers only need to accept the stricter CLI parsing behavior before merge.

Security
Cleared: No concrete security or supply-chain concern found; the diff touches CLI parsing and tests only, adds no dependency, lockfile, workflow, script, download, credential, or publishing changes.

Review details

Best possible solution:

Land the strict parser and focused tests after maintainers accept the CLI compatibility change, then let the linked bug close when the fix merges.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection on current main shows both affected search commands still use Number.parseInt(value, 10), and the PR body supplies before/after source-entry CLI output for the invalid and valid paths.

Is this the best way to solve the issue?

Yes. The PR uses the existing strict positive-integer parser behind a small Commander-only adapter, which is narrower than changing shared helpers or the search action runtime paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against b36fa1d8f1b4.

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a focused CLI bug fix with limited blast radius and no evidence of urgent runtime breakage.
  • merge-risk: 🚨 compatibility: The PR intentionally changes existing CLI behavior for malformed --limit inputs from lenient parsing to parse-time failure.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes copied source-entry terminal output from the current PR head showing invalid plugin and skill search limits fail and valid +1 limits execute the real search path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied source-entry terminal output from the current PR head showing invalid plugin and skill search limits fail and valid +1 limits execute the real search path.
Evidence reviewed

PR surface:

Source +12, Tests +73. Total +85 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 14 2 +12
Tests 2 75 2 +73
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 89 4 +85

What I checked:

  • Current plugins search parser is lenient on main: Current main still registers plugins search --limit with Number.parseInt(value, 10), so a value like 1abc is parsed as 1 before the search action runs. (src/cli/plugins-cli.ts:78, b36fa1d8f1b4)
  • Current skills search parser is lenient on main: Current main still registers skills search --limit with Number.parseInt(value, 10), matching the linked bug's central behavior. (src/cli/skills-cli.ts:127, b36fa1d8f1b4)
  • Existing strict parser matches the proposed validation rule: parseStrictPositiveInteger accepts only safe whole integers greater than zero and rejects partial numerics, decimals, zero, and negatives. (src/infra/parse-finite-number.ts:34, b36fa1d8f1b4)
  • PR head keeps the Commander adapter out of shared helpers: The final PR diff adds src/cli/positive-integer-option.ts, importing InvalidArgumentError only in the CLI option adapter and reusing parseStrictPositiveInteger. (src/cli/positive-integer-option.ts:1, 80c08226f0d9)
  • Commander contract supports parse-time invalid-argument failures: Commander 14.0.3 exposes InvalidArgumentError with code commander.invalidArgument and exit code 1, and its command parser catches that code from custom option parsers before action execution. (package.json:1823, b36fa1d8f1b4)
  • PR proof exercises the real source-entry command path: The PR body includes copied terminal output from head 80c08226f0d96f9d7436da20822cdf6354c6983d showing both invalid plugin and skill search limits exit 1, while +1 reaches the real search action for both commands. (80c08226f0d9)

Likely related people:

  • steipete: Peter Steinberger authored the native ClawHub skill search path that introduced the skills search --limit parseInt pattern and also authored the shared strict numeric parser this PR reuses. (role: feature-history owner; confidence: high; commits: 91b2800241c1, 2646739d2334; files: src/cli/skills-cli.ts, src/infra/parse-finite-number.ts, src/cli/program/helpers.ts)
  • vincentkoc: Recent history and blame on the checked-out main tree show Vincent Koc carrying the current CLI files and touching adjacent plugin CLI surfaces. (role: recent area contributor; confidence: medium; commits: fb853de5542a, 74e7b8d47b18; files: src/cli/plugins-cli.ts, src/cli/skills-cli.ts, src/infra/parse-finite-number.ts)
  • jbetala7: The PR author also appears in the provided related context as the author of a merged adjacent strict tasks audit --limit validation fix, so they have relevant recent CLI limit-parser context beyond this PR. (role: adjacent fix owner; confidence: medium; commits: 44d470f7ebb7; files: src/cli/program/register.status-health-sessions.ts, src/cli/program/helpers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🌱 uncommon Frosted Shellbean

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🌱 uncommon.
Trait: stacks clean commits.
Image traits: location diff observatory; accessory CI status badge; palette charcoal, cyan, and signal green; mood focused; pose balancing on a branch marker; shell smooth pearl shell; lighting gentle morning glow; background little resolved-comment flags.
Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Frosted Shellbean in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@jbetala7
jbetala7 force-pushed the fix/84473-search-limit-parser branch from e8bcf8b to b2c536f Compare May 24, 2026 19:29
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 24, 2026
@jbetala7

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@jbetala7

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 24, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 24, 2026
@jbetala7
jbetala7 force-pushed the fix/84473-search-limit-parser branch from b2c536f to 80c0822 Compare May 26, 2026 18:59
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 26, 2026
@jbetala7

Copy link
Copy Markdown
Contributor Author

Addressed the ClawSweeper helper-boundary finding in head 80c08226f0.

The Commander InvalidArgumentError adapter now lives in src/cli/positive-integer-option.ts, while src/cli/program/helpers.ts is back to type-only Commander imports and dependency-free strict integer helper reuse. I also moved the direct option-parser coverage into the plugins/skills command paths, including a valid +10 parse-path assertion.

Validation rerun on the current head:

  • node scripts/run-vitest.mjs src/cli/program/helpers.test.ts src/cli/plugins-cli.lazy.test.ts src/cli/skills-cli.commands.test.ts (3 files, 72 tests passed)
  • ./node_modules/.bin/oxfmt --check --threads=1 src/cli/program/helpers.ts src/cli/positive-integer-option.ts src/cli/plugins-cli.ts src/cli/skills-cli.ts src/cli/program/helpers.test.ts src/cli/plugins-cli.lazy.test.ts src/cli/skills-cli.commands.test.ts
  • git diff --check
  • source-entry CLI proof in the PR body now covers invalid 1abc rejection and valid +1 execution for both plugins and skills search

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: supplied External PR includes structured after-fix real behavior proof. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 26, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels May 26, 2026
@jbetala7

Copy link
Copy Markdown
Contributor Author

Superseded by upstream. Issue #84473 is now fixed on main by commit d2d5010 ("fix: reject partial numeric CLI options"), which adds parseStrictPositiveIntOption in src/cli/program/helpers.ts and wires it into both affected call sites:

  • openclaw plugins search --limit (src/cli/plugins-cli.ts:79)
  • openclaw skills search --limit (src/cli/skills-cli.ts:176)

That matches this PR's behavior exactly (both reject partially-numeric values like 5abc via InvalidArgumentError), using the shared parseStrictPositiveInteger helper. Closing this PR as redundant since the fix already landed.

@jbetala7 jbetala7 closed this May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI search --limit accepts partially numeric values

1 participant