Repository navigation
fix(gateway): blank --url silently reports the default gateway status - #193697
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 probe diagnostics begin. 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 silently discards blank URL targets, and this PR provides a focused fix with no actionable findings. Current-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCommander passes URL options to the status and probe command owners, which select Gateway targets and render human-readable or JSON diagnostics. flowchart TD
A[CLI URL option] --> B[Status command]
A --> C[Probe command]
B --> D[Blank input rejection]
C --> D
B --> E[Service diagnostics]
C --> F[Gateway target probes]
Technical reviewBest possible solution: Land the two command-entry checks once the existing current-head CI gate passes. Do we have a high-confidence way to reproduce the issue? Yes: current-main source traces blank input into default-target selection, and the contributor supplies matching built-CLI before/after results; no target code was executed during this review. Is this the best way to solve the issue? The defect is lost explicit-target intent; the invariant is that a supplied blank URL cannot select defaults, and the smallest complete fix is rejection at these two existing command owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e792f74abfea. 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
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 HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 7:25 AM ET / 12:25 UTC (Revision 2). |
166efe4 to
d2f9e88
Compare
yxshee
left a comment
There was a problem hiding this comment.
Review draft: #193697 (fix(gateway): reject a blank --url instead of probing the default Gateway)
Post as a PR review (Comment, not Approve/Request changes; contributor review). Static review: the auto-mode classifier blocked running this branch locally, so these notes come from the diff, the surrounding code on main (826999c), and the shipped behaviour of gatewayAction / runDaemonStatus.
Read through both drop points against main and the fix lands at the right layer: runDaemonStatus is the only engine behind gateway status, and gatewayStatusCommand the only one behind gateway probe, so a check at each entry covers every route in before ensureExplicitGatewayAuth, resolveTargets or gatherDaemonStatus can turn "" into "absent".
Checked how the two errors surface, since they use different shapes:
gateway status --url ""goes throughfailDaemonStatus, so human output isGateway status failed: --url must not be blankand--jsonis the canonical{ ok: false, error: { type: "cli_error", … } }document. Matches the newstatus.test.tscase.gateway probe --url ""throws a plainError. That is fine here becausegatewayAction(src/cli/gateway-cli/gateway-action.ts) printsformatErrorMessage(err)for non-expected errors in human mode andformatCliJsonFailure(err)in JSON mode, so the operator still sees--url must not be blankrather than the generic "The CLI command failed." line. Worth one sentence in the body, since most thrown plain errors elsewhere in the CLI do end up generic.
Two small things, neither blocking:
- The two messages differ (
Gateway status failed: --url must not be blankvs--url must not be blank).gateway probehas nolabelin itsgatewayAction, so aGateway probe failed:prefix would need to come from the thrown message itself; consistent wording across the two commands would make the error easier to grep for in scripts. opts.url !== undefined && !opts.url.trim()also catches--url " ", which thegateway-status.test.tscase covers; thestatus.test.tscase only covers"". Not needed for coverage, just noting the asymmetry.
The test-line allocation is annotated and the four new assertions are the right ones (no readBestEffortConfig, no probeGateway, no gatherDaemonStatus call before the rejection). LGTM from my side.
d2f9e88 to
17f4158
Compare
|
Thanks for the careful review, @yxshee — both notes were accurate and I've acted on the wording one. Updated On the whitespace asymmetry note: @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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).