Skip to content

fix(gateway): blank --url silently reports the default gateway status - #197626

Closed
wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/gateway-status-blank-url
Closed

wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/gateway-status-blank-url

Conversation

@wangmiao0668000666

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw gateway status --url "" (or --url "$VAR" where the variable is empty) exits 0 and prints the configured default Gateway's service/connectivity report instead of rejecting the blank target. The same command with a non-empty --url ws://… probes exactly that URL, so an explicitly passed empty value is silently treated as "flag not provided" while any other value is honored.

openclaw gateway probe --url "" has the same silent drop: it prints the full Gateway Status report for the configured local/remote targets (byte-identical to running gateway probe with no --url at all).

Root cause: two independent drop points turn "" into "absent" before any target is resolved.

  • src/commands/gateway-status.ts (gatewayStatusCommand, the engine behind gateway probe): ensureExplicitGatewayAuth({ urlOverride: opts.url?.trim() }) early-returns on an empty override, resolveTargets() maps "" → normalizeWsUrl → null (no explicit target), and hasExplicitUrl reads opts.url.trim().length > 0 → false.
  • src/cli/daemon-cli/status.ts (runDaemonStatus, behind gateway status): opts.rpc.url is passed straight through and status.gather.ts treats a falsy override as "use the configured target" (if (opts.deep && !trimToUndefined(opts.rpc.url))).

User Impact

User impact: scripts and operators that pass an empty --url (typically --url "$GATEWAY_URL" with an unset variable) now get a clear error and exit 1 instead of a successful report about a different Gateway than the one they asked about — before any probe, SSH tunnel, Bonjour discovery, or service inspection starts. Blank values fail at command entry, so no partial output is produced.

Why This Change Was Made

Adds a 3-line blank check at the top of gatewayStatusCommand and a 4-line blank check at the top of runDaemonStatus, reusing the repository's existing must not be blank contract (the same wording and shape as agentCliCommand in src/commands/agent-via-gateway.ts, account-selector.ts, channel-selector.ts, and the merged --agent must not be blank guard from #193336). Each check sits at the entry of the command that owns the --url option, before any of its consumers run.

Not introducing: no new error type, no config validation, no shared resolver change, no owner/state/schema/API change, no SDK-visible surface. resolveGatewayRpcOptions / addGatewayClientOptions (shared by gateway call, health, stability, diagnostics export, exec-policy, …) are deliberately untouched — that is a wider family with its own blast radius and is recorded as a follow-up rather than folded into this fix.

Evidence

Base 37706a74a81129f8ec85289399a2703abf98c2b4 (branch base = origin/main at branch creation) → Candidate 166efe4ed6ad68a3dceeee079eececc8dbfd564f (branch fix/gateway-status-blank-url).

Environment: Linux x64, Node v24.22.1, normally built openclaw.mjs (OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build:docker), isolated OPENCLAW_HOME + OPENCLAW_STATE_DIR (+ isolated HOME), no Gateway running, no network dependency, no seed data. Every case below was run twice; each pair was compared with cmp (exit code + stdout + stderr), not by eye.

Shipped CLI (each leg run at least twice)

case base candidate
gateway status --url "" ×2 exit 0, stdout+stderr byte-identical to gateway status with no flag (md5 358f247acd194509801e9873eed89e45 / f8cb63b30f259108654742cce8c82c30) — blank silently dropped exit 1, stderr Gateway status failed: --url must not be blank
gateway status (no --url) ×2 exit 0 exit 0, byte-identical to base
gateway status --url "ws://127.0.0.1:9" ×2 exit 0, Check target: ws://127.0.0.1:9 (explicit target honored) exit 0, byte-identical to base
gateway probe --url "" ×2 exit 1, stdout+stderr byte-identical to gateway probe with no flag (stdout md5 f930c0cfd768d2f066ce142512e2e10d, stderr empty d41d8cd98f00b204e9800998ecf8427e) — blank silently dropped exit 1, stderr --url must not be blank
gateway probe (no --url) ×2 exit 1 (Gateway Status / Reachable: no) exit 1, byte-identical to base
gateway probe --url "ws://127.0.0.1:9" ×2 exit 1, explicit target probed exit 1, byte-identical to base

All eight "unchanged" comparisons were byte-identical (cmp clean on both streams) between the base build and the candidate build in the same isolated home/state directory.

Regression RED → GREEN (remote, real vitest)

Remote proof host (Docker lexiflow-all:latest, Node v24.22.1, OPENCLAW_VITEST_RUNTIME=node), production files at 37706a74a81 bytes (verified md5-identical to git show origin/main:<path> for all four files before the run):

sh node_modules/.bin/vitest run --config test/vitest/vitest.commands.config.ts \
  src/commands/gateway-status.test.ts --maxWorkers=1
sh node_modules/.bin/vitest run --config test/vitest/vitest.cli.config.ts \
  src/cli/daemon-cli/status.test.ts --maxWorkers=1
  • base production + new test → RED. commands shard: 1 failed | 30 passed (31) — rejects a blank --url before reading config or probing fails with AssertionError: promise resolved "undefined" instead of rejecting at src/commands/gateway-status.test.ts:234 (the blank value silently proceeded past the guard). cli shard: 1 failed | 7 passed (8) — rejects a blank --url before gathering status fails with the same promise resolved "undefined" instead of rejecting at src/cli/daemon-cli/status.test.ts:140.
  • candidate production + the same tests → GREEN. commands shard: 31 passed (31); cli shard: 8 passed (8) (the new rejects a blank --url before gathering status case is green).
  • Siblings/consumers on the candidate (all green): src/cli/gateway-cli.coverage.test.ts, src/cli/gateway-cli/register.option-collisions.test.ts, src/cli/daemon-cli/register-service-commands.test.ts, src/cli/daemon-cli/status.install-hints.test.ts, src/cli/daemon-cli/status.gather.test.ts, src/cli/daemon-cli/status.print.test.ts → 6 passed (6) files, 156 passed | 2 skipped (158); src/commands/gateway-status/helpers.test.ts (root matrix) → 1 passed (1) file, 18 passed (18).

Local gates

oxlint (v1.88.0) src/commands/gateway-status.ts src/commands/gateway-status.test.ts src/cli/daemon-cli/status.ts src/cli/daemon-cli/status.test.ts → 0 findings, exit 0
node scripts/run-format.mts --check <those four files> → All matched files use the correct format
node scripts/check-test-lines-ratchet.mts --base 37706a74a81 → Test lines OK (allocation credit equals this PR's +18 delta)
git diff --check → clean

Line counts

Whole-PR delta: production +7/-0 (2 files), tests +18/-0 (2 files), config/test-lines-allocations/gateway-status-blank-url.txt = 18 for exactly this PR's net test growth. Shared scalar config/test-lines-baseline.txt untouched. On a clean 37706a74a81 the ratchet reports Test lines OK: 6496704; ceiling: 6496746; slack: 42, so this branch stays inside the ceiling with the allocation applied.

Negative claims

  • Not claimed: gateway status/gateway probe against a running Gateway — both legs run with no listener, and the proof is exit code + byte-identical output identity, not live capability data.
  • Not claimed: the shared --url consumers (gateway call, health, stability, diagnostics export, exec-policy, …). They share the shape but are a wider family; fixing them belongs to a separate, explicitly scoped change.
  • Not claimed: whitespace-only --url " " at the CLI (covered by the same .trim() expression; the shipped CLI leg exercises "", and the unit test exercises both "" and " " for gateway probe).

Focused Checks and Simplification

  • 7 production lines across 2 production files; each guard is a straight-line if at the existing command entry, no helper, no wrapper, no new export, no new error class.
  • Tests were merged into the two files that already own these commands (gateway-status.test.ts, status.test.ts), reusing their existing mock-not-called assertions so no new harness was introduced.
  • Test-lines: this PR adds an allocation of exactly its +18 growth and leaves the shared scalar alone.

Compatibility and Merge Risk

Two-way door: reverting restores the previous silent fallback without migrations or persisted state changes. Blast radius is --url validation at exactly two command entries (gateway status, gateway probe); both fail before config reads, probes, SSH tunnels, Bonjour discovery, and service inspection. Unchanged adjacent behavior: omitted --url, non-empty valid URLs, non-empty invalid URLs (still probed and reported as before), --token/--password/--port/--ssh handling, --json output shape for every non-blank case, and every other command.

Collision check (run against origin/main minutes before opening): no open PR modifies src/commands/gateway-status.ts, src/commands/gateway-status.test.ts, src/cli/daemon-cli/status.ts, or src/cli/daemon-cli/status.test.ts; gh pr list --search "gateway status" / "blank url" and per-file gh api pulls/<n>/files checks returned only unrelated work (the one parallel-lane PR touching remote URLs, #193538, edits src/commands/onboard-remote.ts only).

Status

Reopened: this pull request was closed by mistake during a session cleanup on 2026-11-12 while it was still proof: sufficient + ready for maintainer look. The branch was rebased onto 611bea727f21 (the only conflict was a neighbouring test in status.test.ts, resolved by keeping both cases) and the diff is byte-identical to the previously reviewed head. No new behavior was added.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: XS labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Reject explicitly empty or whitespace-only --url values before gateway status or gateway probe begins diagnostics.

Example: Run openclaw gateway status --url "".

  • Before: The command reports the default Gateway's status and exits 0.
  • After: The command reports “Gateway status failed: --url must not be blank” and exits 1.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused boundary repair with shipped-CLI evidence, reported red/green regressions, and no actionable correctness or security findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied built-CLI output exercises both command owners in isolated Linux with Node 24.22.1, showing blank rejection and unchanged omitted/nonblank controls; the identical predecessor guards and reported prefix retest support reuse after rebasing.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An explicitly blank URL silently selects default Gateway diagnostics, misleading operators and scripts about the requested target.
Reason: Rejecting invalid explicit input restores target intent without adding settings, changing valid routes, or expanding shared-client policy.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still discards blank URL overrides, and this PR provides a minimal, useful fix with supplied shipped-CLI evidence and no actionable findings.

Priority: P2
Reviewed head: 25e743e0fcf6e7125372afbd47d8bbe6d8907814

Before merge

None.

Findings

None.

Agent review details

How this fits together

CLI option registration passes URL values to the status and probe command owners, which resolve targets, inspect services or connectivity, and render text or JSON diagnostics.

flowchart TD
  A[CLI URL option] --> B[Status command]
  A --> C[Probe command]
  B --> D[Reject blank URL]
  C --> D
  B --> E[Service diagnostics]
  C --> F[Gateway target probes]
Loading

Technical review

Best possible solution:

Land the two command-entry checks using the existing error owners.

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

Current-main source traces blank input into default-target selection, matching the contributor's built-CLI before/after results; this review executed no target code.

Is this the best way to solve the issue?

The defect is lost explicit-target intent; rejecting blank values at these two existing command owners is the smallest complete fix and preserves omitted and nonblank input behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7ea57a8cba1a.

Provenance checked

  • Gateway target selection and explicit credentials keeps the original intent (5b50c97: The original implementation combines explicit, configured remote, and local targets; the later explicit-auth repair prevents ambient credentials reaching overridden URLs.)
  • Daemon status error rendering keeps the original intent (433bb3f: The CLI reliability repair established early command validation and a single daemon failure renderer, which the added guard reuses.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 433bb3f adds src/cli/daemon-cli/status.ts:8 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 433bb3f954ed; files: src/cli/daemon-cli/status.ts)

PR surface

Source +7, Tests +18, Other +2. Total +27 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 7 0 +7
Tests 2 18 0 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 5 27 0 +27

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression growth Production +7/-0; tests +18/-0 Two existing command boundaries require separate regressions without new helpers or test scaffolding.

Root-cause cluster

Relationship: canonical
Canonical: #197626
Summary: This PR carries forward the focused fix from its closed, unmerged predecessor.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Empty shell-expanded URL values can produce misleading default-target diagnostics in operator scripts.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 12, 2026, 3:15 AM ET / 08:15 UTC.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this: it doesn't show a real user-facing problem (no report from an affected user and no natural reproduction), and it follows a pattern of small, speculative or duplicate changes split across many PRs. Please open an issue with a reproduction of real harm first; a fix can follow once the problem is confirmed.

@obviyus obviyus closed this Nov 16, 2026
@wangmiao0668000666
wangmiao0668000666 deleted the fix/gateway-status-blank-url branch November 17, 2026 01:32
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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

2 participants