Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Thanks for the context here. I did a careful shell check against current Close: current main now covers the stale Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the current-main combination of stable subset request IDs and sanitized Do we have a high-confidence way to reproduce the issue? No. The old branch-base behavior was source-reproducible, but current main now emits a sanitized Is this the best way to solve the issue? No. This branch was a plausible narrow fix when opened, but the best current solution is the merged main path from #98145 and #98146. Security review: Security review needs attention: The branch would introduce an unsanitized terminal/log diagnostic for a CLI-supplied request id in the device approval flow.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 9d68f877ac3e; fix evidence: commit 9003042c5fa0, main fix timestamp 2026-07-01T05:17:42Z. |
7311275 to
1179430
Compare
1179430 to
49a2462
Compare
49a2462 to
83b8289
Compare
|
Heads up: this PR needs to be updated against current |
3a8b38e to
ab1d5ba
Compare
ab1d5ba to
50b3b17
Compare
|
Thanks for the detailed production proof. Closing as superseded. Current main fixes both sides of this failure: #98145 preserves the request ID for covered subset re-requests, and #98146 replaces the dead-end error with a sanitized The remaining branch-only pending-count diagnostic is no longer needed and lacks current main's input sanitization. If a distinct current-release approval failure remains, please open a focused report with redacted device-request state. |
Summary
openclaw devices approve <requestId>on a loopback gateway has a localfile fallback path (
src/cli/devices-cli.runtime.ts:220-271(post-refactor; wassrc/cli/devices-cli.ts:280-358)) that approvesdirectly against
~/.openclaw/devices/{pending.json,paired.json}whenthe CLI cannot dial the gateway as an admin. The fallback compares the
user-supplied
requestIdagainstrequestIdextracted from thegateway's pairing-required close error. Three branches today:
FALLBACK_STATE_MISMATCH_MESSAGEwithMissing requestId: <gatewayId>.Actionable. ✅
→ throw the same state-mismatch error. Actionable. ✅
user-supplied id → silent
return null. The caller at the caller line in the runtime fileonly logs
defaultRuntime.error("unknown requestId"). ❌Branch 3 fires whenever the gateway emits a
not-pairedclose(
buildPairingConnectErrorMessageinsrc/gateway/protocol/connect-error-details.ts:275-281returns thebare
"pairing required"string without a parenthetical) and theuser-supplied requestId is no longer in
pending.json. The most commonreason for that disappearance is supersession: the gateway dial just
called
requestDevicePairing→reconcilePendingPairingRequests→canRefreshSinglereturned false because the incoming and existingscope sets diverge (
samePendingApprovalSnapshotrequires exact setequality,
src/infra/device-pairing.ts:314-331), so the reconcilerreplaced the entry with a fresh
requestId. Other causes: the 5minute TTL (
PENDING_TTL_MSatsrc/infra/device-pairing.ts:132) orrunning approve under a different
OPENCLAW_PROFILE/OPENCLAW_STATE_DIR.The operator is left with
unknown requestIdand no pointer to thecurrent pending state or what to do next.
Reproduction (before)
ECS Fargate container running
ghcr.io/openclaw/openclaw:2026.5.7,Linux x86_64, loopback gateway, paired operator device with only
operator.read. Generated a pending request viaopenclaw devices approve --latestpreview (which builds ascope-upgrade request for the full
CLI_DEFAULT_OPERATOR_SCOPESset),then ran the explicit approve:
11e7be5awas the user-supplied id from the preview. The dial built anew pending whose scope set was a narrower subset of the user-supplied
one (just
operator.pairingto calldevice.pair.approve); thereconciler replaced rather than refreshed and
11e7be5awas gone bythe time the fallback ran. The operator has no way to discover from
this output that the current pending entry exists locally.
Fix
Replace the silent
return nullwith a thrownErrorwhose messageincludes:
prune, profile mismatch)
openclaw devices listThe diagnostic never prints a direct
Rerun: openclaw devices approve <id>command, even when only one other pending entry is visible. Three
plausible causes (TTL prune, profile/state mismatch, multi-device
profile churn) can each produce a single visible pending that is
unrelated to the operator's intent. The earlier ClawSweeper review
(
P2: Single pending request can be unrelated) called this outexplicitly. Routing through
openclaw devices listforces theoperator to verify deviceId + requested scopes before approving,
matching the existing implicit-approve
--latestflow which is alsopreview-only.
No behavior change to the approval semantics in any branch. The other
two error paths (mismatched gatewayRequestId, gatewayRequestId matches
but pending missing) keep the existing
buildFallbackStateMismatchErrortext; only the previously silent
return nullpath now throws anactionable error.
After
No other pending entries
One other pending entry (still routes to
list— could be unrelated)Multiple other pending entries
Tests
Extends
src/cli/devices-cli.test.tswith three regressions inside theexisting
devices cli local fallbackdescribe block:openclaw devices listwhen a single otherpending request is visible" — drives the new code path end-to-end
with exactly one other pending entry. Both
device.pair.list(theprecheck scope resolver) and
device.pair.approvereject with abare
pairing requiredmessage (no requestId),approveDevicePairingreturnsundefinedfor the supplied id, anda freshly mocked
listDevicePairingis the only way to surface thealternative. Asserts the rejected error contains the
1 other pending request is visibleline + theopenclaw devices listrouting, and asserts the error does NOT contain a
Rerun:line.are visible locally" — same setup but pending list is empty.
Asserts the error switches to
No other pending requests are visible.visible" — same setup but two other pending entries. Asserts the
error routes to
openclaw devices listAND does not contain aRerun:line.No changes to
CHANGELOG.mdper contributor convention.Why the CLI layer and not the dial/reconciler
I considered two deeper fixes and rejected both as out of scope for a
behaviour-preserving error-surface change:
reconcilePendingPairingRequests.samePendingApprovalSnapshotgating refresh on exact scope-set equality is intentional — the
replacement branch already merges scopes upward
(
src/infra/device-pairing.ts:546-558), so the new pending coversthe user's intent; only the identifier changes. Allowing refresh on
superset/subset relationships would change persisted-state
semantics on every cron's connect handshake, well beyond the bug
this addresses.
approve <id>is a contract the operator typed explicitly;silently approving a different id under the same command would
surprise scripts and audit trails. The CLI's existing pattern (the
mismatched-id branch at devices-cli.ts:311-313) chooses error over
redirect, and this PR keeps that posture. The diagnostic always
routes through
openclaw devices listso the operator choosesexplicitly after seeing deviceId + scopes.
Why not auto-suggest the single visible pending entry
ClawSweeper flagged this on the first revision of this PR
(
P2: Single pending request can be unrelated). Earlier revisions ofthis fix attempted to print
Rerun: openclaw devices approve <id>whenever exactly one alternativepending request was visible. Counter-examples:
PENDING_TTL_MS = 5 minutes. If the operator's staleid expired and a different agent (with a different deviceId)
subsequently created a pending request, the local profile shows one
pending entry — but it is not the replacement for the stale request.
different
OPENCLAW_STATE_DIRthan the gateway. The one visiblelocal pending request is local-only and unrelated to the gateway's
current view.
loopback gateway race; either's pending request can be the one
visible at the moment the fallback runs.
Routing through
openclaw devices listfor the operator to inspectdeviceId + requested scopes before approving is the same safety the
existing
--latest/implicit-approve preview flow uses(
src/cli/devices-cli.ts:703+).Real Behavior Proof
Behavior or issue addressed:
openclaw devices approve <id>on aloopback gateway returns the bare error
unknown requestIdwheneverthe supplied requestId is missing from local
pending.jsonand thegateway's close error did not carry a requestId in its parenthetical.
The operator has no way to discover from this output that other
pending entries exist or what to do next.
Real environment tested:
ghcr.io/openclaw/openclaw:2026.5.7on Linux x86_64, loopbackgateway with
auth.mode: "token", accessed viaaws ecs execute-command. Capturedunknown requestIdfrom thepatched-CLI repro path.
(
pnpm build) and ran it against a localopenclaw gateway --devinstance with an isolated
OPENCLAW_STATE_DIR=/tmp/openclaw-pr-evidenceon macOS arm64 (Node 22.18.0).
Steps run after the patch:
Build the patched CLI, start an isolated dev gateway, auto-pair the CLI
device, stage the bug scenario (downgrade scopes + seed a stale pending
whose scope set is broader than what the dial will ask for), then run
the patched approve:
A small Python helper between
devices listanddevices approvemutatesdevices/paired.json(downgrade scopes tooperator.read) anddevices/pending.json(insert the stale id with the broader scope set);omitted here for brevity.
After-fix evidence (single visible alternative — original bug reproduction):
After-fix evidence (multi-pending case — staged with 4 fake pending entries from different deviceIds):
After-fix evidence (no other pending case — also covered by unit regression):
Observed result after fix: The operator always gets a routing to
openclaw devices listplus a count of visible pending entries. Theynever get a direct
Rerun:command that could approve an unrelateddevice's request. The original ECS-Fargate bug scenario matches the
single-visible-alternative case (after
--latest-preview-drivensupersession), with the operator now seeing the actionable diagnostic
instead of the dead-end
unknown requestId.What was not tested: I did not rebuild the OpenClaw container
image with this patch and redeploy it onto the original ECS Fargate
task. The local dev-gateway reproduction stages the exact failure
path (
reconcilePendingPairingRequestsreplacing the user-suppliedpending entry during the gateway dial, then the local fallback
running with no matching id), and the patched CLI is the actual
binary built from this branch's commits. A maintainer who wants live
ECS confirmation can stage the patched image, run the two-command
repro above, and read the new error text.