← Back to PRs

#17279: fix: restore device token priority over config token

by MisterGuy420 open 2026-02-15 16:07 View on GitHub →
gateway stale size: XS trusted-contributor
## Summary Restores the token priority to storedToken ?? this.opts.token, fixing the device token auth regression in v2026.2.14. Previously paired devices now correctly authenticate via their stored device tokens instead of the shared config token. ## Changes - Changed token priority in src/gateway/client.ts from this.opts.token ?? storedToken back to storedToken ?? this.opts.token - Added canFallbackToShared boolean to track when both stored and config tokens are available - Restored self-healing mechanism in catch handler that clears stale device tokens on connection failure - Added clearDeviceAuthToken import ## Testing - TypeScript compilation passes (pnpm tsgo) - Gateway tests pass (1 pre-existing unrelated failure in server-runtime-config.test.ts) Fixes openclaw/openclaw#17270 <!-- greptile_comment --> <h3>Greptile Summary</h3> Correctly restores device token priority over shared config tokens, fixing a regression where paired devices incorrectly used shared config tokens instead of their device-specific tokens. - Changed token resolution from `this.opts.token ?? storedToken` back to `storedToken ?? this.opts.token` (src/gateway/client.ts:197) - Restored self-healing mechanism that clears stale device tokens on connection failure when both tokens are available (src/gateway/client.ts:284-291) - Added `canFallbackToShared` boolean to track when fallback is possible (src/gateway/client.ts:198) <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The fix correctly restores the intended token priority logic and self-healing mechanism. The change is well-tested (tests pass), minimal in scope (only affects token selection logic), and addresses a clear regression introduced in a previous commit. The logic is straightforward and properly handles the fallback scenario. - No files require special attention <sub>Last reviewed commit: 0f8262b</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs