Skip to content

Commit 27d05f1

Browse files
patnikoCopilot
andcommitted
fix: add null guards for _client in Python v3 handlers
The ty type checker correctly identifies that self._client can be None. Add explicit guards before the .request() calls in the v3 broadcast event handlers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 929baa4 commit 27d05f1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

python/copilot/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,8 @@ async def _handle_external_tool_requested(self, session_id: str, event_dict: dic
15381538
session_id, tool_call_id, tool_name, arguments, handler
15391539
)
15401540

1541+
if not self._client:
1542+
return
15411543
await self._client.request(
15421544
"session.tools.handlePendingToolCall",
15431545
{
@@ -1583,6 +1585,8 @@ async def _handle_permission_requested_event(self, session_id: str, event_dict:
15831585
return
15841586

15851587
result = await session._handle_permission_request(permission_request)
1588+
if not self._client:
1589+
return
15861590
await self._client.request(
15871591
"session.permissions.handlePendingPermissionRequest",
15881592
{

0 commit comments

Comments
 (0)