fix: WebSocket auth handshake overwriting explicit workspace (#965)

The auth-ok response includes the token's bound workspace, and
AsyncSocketClient was unconditionally adopting it — clobbering any
workspace the caller explicitly requested via the constructor.
This commit is contained in:
cybermaggedon 2026-06-01 12:24:27 +01:00 committed by GitHub
parent c460f62c87
commit 9e0c848057
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -30,6 +30,7 @@ class AsyncSocketClient:
self.timeout = timeout self.timeout = timeout
self.token = token self.token = token
self.workspace = workspace self.workspace = workspace
self._workspace_explicit = workspace != "default"
self._request_counter = 0 self._request_counter = 0
self._socket = None self._socket = None
self._connect_cm = None self._connect_cm = None
@ -92,7 +93,8 @@ class AsyncSocketClient:
) )
if resp.get("type") == "auth-ok": if resp.get("type") == "auth-ok":
self.workspace = resp.get("workspace", self.workspace) if not self._workspace_explicit:
self.workspace = resp.get("workspace", self.workspace)
elif resp.get("type") == "auth-failed": elif resp.get("type") == "auth-failed":
await self._socket.close() await self._socket.close()
raise ProtocolException( raise ProtocolException(