Repository navigation
fix(gateway): blank --url silently reports the default gateway status - #197626
wangmiao0668000666 wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesReject explicitly empty or whitespace-only --url values before gateway status or gateway probe begins diagnostics. Example: Run openclaw gateway status --url "".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCLI 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests +18, Other +2. Total +27 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 12, 2026, 3:15 AM ET / 08:15 UTC. |
|
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. |
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 fullGateway Statusreport for the configured local/remote targets (byte-identical to runninggateway probewith no--urlat all).Root cause: two independent drop points turn
""into "absent" before any target is resolved.src/commands/gateway-status.ts(gatewayStatusCommand, the engine behindgateway probe):ensureExplicitGatewayAuth({ urlOverride: opts.url?.trim() })early-returns on an empty override,resolveTargets()maps""→normalizeWsUrl→null(no explicit target), andhasExplicitUrlreadsopts.url.trim().length > 0→false.src/cli/daemon-cli/status.ts(runDaemonStatus, behindgateway status):opts.rpc.urlis passed straight through andstatus.gather.tstreats 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
gatewayStatusCommandand a 4-line blank check at the top ofrunDaemonStatus, reusing the repository's existingmust not be blankcontract (the same wording and shape asagentCliCommandinsrc/commands/agent-via-gateway.ts,account-selector.ts,channel-selector.ts, and the merged--agent must not be blankguard from #193336). Each check sits at the entry of the command that owns the--urloption, 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 bygateway 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/mainat branch creation) → Candidate166efe4ed6ad68a3dceeee079eececc8dbfd564f(branchfix/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), isolatedOPENCLAW_HOME+OPENCLAW_STATE_DIR(+ isolatedHOME), no Gateway running, no network dependency, no seed data. Every case below was run twice; each pair was compared withcmp(exit code + stdout + stderr), not by eye.Shipped CLI (each leg run at least twice)
gateway status --url ""×2gateway statuswith no flag (md5358f247acd194509801e9873eed89e45/f8cb63b30f259108654742cce8c82c30) — blank silently droppedGateway status failed: --url must not be blankgateway status(no--url) ×2gateway status --url "ws://127.0.0.1:9"×2Check target: ws://127.0.0.1:9(explicit target honored)gateway probe --url ""×2gateway probewith no flag (stdout md5f930c0cfd768d2f066ce142512e2e10d, stderr emptyd41d8cd98f00b204e9800998ecf8427e) — blank silently dropped--url must not be blankgateway probe(no--url) ×2Gateway Status / Reachable: no)gateway probe --url "ws://127.0.0.1:9"×2All eight "unchanged" comparisons were byte-identical (
cmpclean 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, Nodev24.22.1,OPENCLAW_VITEST_RUNTIME=node), production files at37706a74a81bytes (verified md5-identical togit show origin/main:<path>for all four files before the run):commandsshard:1 failed | 30 passed (31)—rejects a blank --url before reading config or probingfails withAssertionError: promise resolved "undefined" instead of rejectingatsrc/commands/gateway-status.test.ts:234(the blank value silently proceeded past the guard).clishard:1 failed | 7 passed (8)—rejects a blank --url before gathering statusfails with the samepromise resolved "undefined" instead of rejectingatsrc/cli/daemon-cli/status.test.ts:140.commandsshard:31 passed (31);clishard:8 passed (8)(the newrejects a blank --url before gathering statuscase is 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
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 scalarconfig/test-lines-baseline.txtuntouched. On a clean37706a74a81the ratchet reportsTest lines OK: 6496704; ceiling: 6496746; slack: 42, so this branch stays inside the ceiling with the allocation applied.Negative claims
gateway status/gateway probeagainst a running Gateway — both legs run with no listener, and the proof is exit code + byte-identical output identity, not live capability data.--urlconsumers (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.--url " "at the CLI (covered by the same.trim()expression; the shipped CLI leg exercises"", and the unit test exercises both""and" "forgateway probe).Focused Checks and Simplification
ifat the existing command entry, no helper, no wrapper, no new export, no new error class.gateway-status.test.ts,status.test.ts), reusing their existing mock-not-called assertions so no new harness was introduced.Compatibility and Merge Risk
Two-way door: reverting restores the previous silent fallback without migrations or persisted state changes. Blast radius is
--urlvalidation 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/--sshhandling,--jsonoutput shape for every non-blank case, and every other command.Collision check (run against
origin/mainminutes before opening): no open PR modifiessrc/commands/gateway-status.ts,src/commands/gateway-status.test.ts,src/cli/daemon-cli/status.ts, orsrc/cli/daemon-cli/status.test.ts;gh pr list --search "gateway status"/"blank url"and per-filegh api pulls/<n>/fileschecks returned only unrelated work (the one parallel-lane PR touching remote URLs, #193538, editssrc/commands/onboard-remote.tsonly).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 onto611bea727f21(the only conflict was a neighbouring test instatus.test.ts, resolved by keeping both cases) and the diff is byte-identical to the previously reviewed head. No new behavior was added.