fix(device-pairing): don't churn requestId on subset re-requests (upstream #98145)#2
Merged
Conversation
…nclaw#98145) * fix(device-pairing): don't churn requestId on subset re-requests A reconnect that re-requested a subset of an already-pending device pairing request still superseded it with a fresh requestId. This is the root cause of the "unknown requestId" failures during device approval: 1. A TUI connect files a broad scope-upgrade request; the owner copies its id from `openclaw devices list`. 2. `openclaw devices approve <id>` reconnects as a CLI probe that only needs `operator.pairing` — a subset of the pending scopes. 3. That subset re-request superseded the pending request with a new id, so the originally-listed id no longer existed and approve failed. Refresh the existing request in place when the incoming request only asks for roles/scopes a single pending request (same device key + role) already covers. Escalations that request *more* than the pending request still supersede with a fresh id, so the requestId stays bound to at least the scope snapshot the owner saw (the existing security-motivated behavior and its test are preserved). AI-assisted (Claude Code). * fix(device-pairing): align subset pairing with scope coverage (cherry picked from commit f749de4)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Clean cherry-pick of upstream
f749de4f0a—fix(device-pairing): don't churn requestId on subset re-requests(upstream openclaw#98145, shipped in v2026.7.1-beta.1) — onto the v2026.6.11alfred-brandbase.Why
The v2026.6.11 rebase (alfred.29–.34) landed inside upstream's broken window: the requestId churn exists in 2026.6.11 and its fix only shipped in 2026.7.1-beta.1 (June 30). On this base, any reconnect from an under-scoped paired device supersedes the pending scope-upgrade request with a fresh requestId — so
openclaw devices approve <id>invalidates its own target and dies withunknown requestId.This broke
alfred mail setautopilot on the machines-mini test install (runtime 2026.6.11-alfred.33), captured live:The May tarballs (v2026.5.3-alfred.23 and earlier) predate the churn, which is why this never happened before the new tarball.
With this fix, same-scope re-requests refresh the pending request in place (same device key + role, subset scopes), so the listed requestId stays approvable — and Alfred's mail-sweep auto-approval works again end-to-end. Escalating re-requests still supersede with a fresh id (the security behavior from openclaw#54694 is preserved).
Testing
vitest run src/infra/device-pairing-churn.test.ts src/infra/device-pairing.test.ts src/cli/devices-cli.test.ts— 104/104 pass, including the two new upstream churn tests.requestDevicePairing: 313 pass; the only failures are 3 insrc/commands/doctor-device-pairing.test.tsthat fail identically on the base without this change (pre-existing red).Downstream
approval_superseded); with a fixed runtime it should never trigger.v2026.6.11-alfred.35, then reinstall on machines-mini (its paired CLI device isoperator.read-only; the pending scope-upgrade request will finally be approvable — or runopenclaw onboardonce).🤖 Generated with Claude Code