openclaw - ✅(Solved) Fix getCommandPathInternal uses hardcoded "--" instead of FLAG_TERMINATOR constant [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#83902Fetched 2026-05-20 03:47:08
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
1
Timeline (top)
labeled ×5commented ×1cross-referenced ×1unsubscribed ×1

Fix Action

Fix / Workaround

Severity: low / Confidence: high / Category: bug Triage: confirmed-bug Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18) Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol


Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-17e3589ff2-_a01eeb905b.

PR fix notes

PR #84066: fix(cli): use FLAG_TERMINATOR constant in getCommandPathInternal (#83902)

Description (problem / solution / changelog)

Fixes #83902.

getCommandPathInternal (src/cli/argv.ts:225) was the sole helper in argv.ts comparing arg === "--" against the string literal instead of the imported FLAG_TERMINATOR constant from infra/cli-root-options.ts. Every other helper in the same file (isHelpOrVersionInvocation, hasFlag, hasRootVersionAlias, isRootInvocationForFlags, getFlagValue, getCommandPositionals, etc.) routes its terminator check through FLAG_TERMINATOR. Under the current value ("--") the two paths agree, but any future change to the constant would silently desync command-path resolution from help/version detection — subcommand routing would break in a way that's hard to trace.

Changes

  • src/cli/argv.ts: replace if (arg === "--") in getCommandPathInternal with if (arg === FLAG_TERMINATOR) (single-line fix as the issue recommended). Add a short comment explaining the consistency requirement.
  • src/cli/argv.test.ts: regression test that pulls the live FLAG_TERMINATOR constant from infra/cli-root-options.ts and asserts both getCommandPath and getCommandPathWithRootOptions stop at it. The test will fail if the constant changes without a corresponding update here.

Diff stat: 2 files, +24 / -1.

Real behavior proof

  • Behavior or issue addressed: Sanitized issue evidence — argv.ts:4 imports FLAG_TERMINATOR and uses it in every helper except getCommandPathInternal at line 225, which compares against the string literal "--". The issue's reasoning section notes that any future redefinition of FLAG_TERMINATOR would silently break command-path resolution while help/version detection continues to track the new value.

  • Real environment tested: Local Node 22.x. Probe at /tmp/probe_83902.mjs (a) parses the patched argv.ts and verifies the comparison now uses FLAG_TERMINATOR, no remaining arg === "--" string-literal in getCommandPathInternal, and that === FLAG_TERMINATOR is used 8 times across the file (parser-wide consistency), and (b) replays both the patched and pre-fix shapes against the current "--" terminator (both produce ["status"] — no observable difference under the default config) and a hypothetical "++" terminator (patched correctly stops at "++" and returns ["status"]; buggy ignores the redefined constant and returns ["status", "++"]).

  • Exact steps or command run after this patch: node /tmp/probe_83902.mjs

  • Evidence after fix:

PASS: comparison uses the imported FLAG_TERMINATOR constant
PASS: no remaining `arg === "--"` string-literal comparison
PASS: FLAG_TERMINATOR comparison used 8 times across argv.ts (parser-wide consistency)
PASS: replay (current terminator): patched stops at '--' → ['status']
PASS: replay (current terminator): buggy also stops at '--' → ['status'] — no observable difference under default config
PASS: replay (hypothetical FLAG_TERMINATOR=++): patched correctly stops at '++' → ['status']
PASS: replay (hypothetical FLAG_TERMINATOR=++): buggy ignores the new terminator and treats it as a positional → diverges from patched ['status']

ALL CASES PASS
  • Observed result after fix: Under the current FLAG_TERMINATOR = "--" value, behavior is unchanged (the existing "terminator cuts parsing" test still passes). Under any hypothetical change to the constant, getCommandPath / getCommandPathWithRootOptions track the new value in lock-step with the rest of the parser instead of silently using the old literal.

  • What was not tested: A live build that physically changes FLAG_TERMINATOR to a non-"--" value — the regression test pins the assertion against the imported constant via await import("../infra/cli-root-options.js") so the relationship is enforced at test time, and the source-level probe verifies the comparison shape.

Audit (per CLAUDE rules — all 5 steps)

  • Existing-helper check: Reuses the already-imported FLAG_TERMINATOR constant. No new helper or import. PASS
  • Shared-helper caller check: FLAG_TERMINATOR has 8 usage sites across argv.ts after this patch (was 7); the new one is the same comparison shape as all the others. getCommandPath and getCommandPathWithRootOptions are exported and called by command-path.ts and other CLI plumbing — the behavior change is invisible under the current "--" value and matches the existing usage convention across the parser. PASS
  • Broader-fix rival scan: gh pr list --search '83902 in:title,body' and gh pr list --search 'FLAG_TERMINATOR in:title,body' return no open PRs. PASS
  • Recent-merge audit: git log --oneline -5 -- src/cli/argv.ts shows e1061a8b46 test(live): tolerate provider drift in release checks — unrelated. PASS
  • Prototype-pollution scan: N/A — string comparison.

Changed files

  • src/cli/argv.test.ts (modified, +18/-0)
  • src/cli/argv.ts (modified, +6/-1)

Code Example

FLAG_TERMINATOR,

---

if (arg === "--") {
RAW_BUFFERClick to expand / collapse

Severity: low / Confidence: high / Category: bug Triage: confirmed-bug Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18) Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol

Evidence

  • src/cli/argv.ts:4-4 (FLAG_TERMINATOR)
FLAG_TERMINATOR,
  • src/cli/argv.ts:225-225 (getCommandPathInternal)
if (arg === "--") {

Reasoning

Every other function in argv.ts (isHelpOrVersionInvocation, getFlagValue, hasFlag, hasRootVersionAlias, isRootInvocationForFlags, getCommandPositionalsWithRootOptions) uses the imported FLAG_TERMINATOR constant for the terminator check. getCommandPathInternal is the sole outlier, using a hardcoded literal. If FLAG_TERMINATOR is ever changed in infra/cli-root-options.js, command-path resolution will silently diverge from help/version detection, breaking subcommand routing for any non-"--" terminator value.

Reproduction

Change FLAG_TERMINATOR in src/infra/cli-root-options.ts to any other value; getCommandPath/getCommandPathWithRootOptions will ignore the new terminator while all other argv helpers respect it.

Recommendation

Replace if (arg === "--") with if (arg === FLAG_TERMINATOR) at line 225 of src/cli/argv.ts.

Why existing tests miss this

No tests are listed for this feature group; there are no regression tests exercising getCommandPathInternal with non-standard FLAG_TERMINATOR values.

Suggested regression test

Unit test: assert getCommandPath(['node','openclaw','channels','--','add']) returns ['channels'] (stops at terminator), using the real FLAG_TERMINATOR constant, and fails if the constant differs from '--'.

Minimum fix scope

Single-line change in src/cli/argv.ts replacing the string literal with the imported constant.


Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-17e3589ff2-_a01eeb905b.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING