Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/chat_sdk/adapters/github/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ async def initialize(self, chat: ChatInstance) -> None:
except Exception as error:
self._logger.warn("Could not fetch bot user ID", {"error": str(error)})

self._logger.info("GitHub adapter initialized")

async def _get_http_session(self) -> Any:
"""Return the shared aiohttp session, creating it lazily if needed."""
import aiohttp
Expand Down
2 changes: 2 additions & 0 deletions src/chat_sdk/adapters/google_chat/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ async def initialize(self, chat: ChatInstance) -> None:
{"botUserId": self._bot_user_id},
)

self._logger.info("Google Chat adapter initialized")

async def disconnect(self) -> None:
"""Disconnect the adapter and close the shared HTTP session."""
if self._http_session and not self._http_session.closed:
Expand Down
12 changes: 10 additions & 2 deletions src/chat_sdk/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,11 @@ def channel(self, channel_id: str) -> ChannelImpl:
raise ChatError(f"Invalid channel ID: {channel_id}")
adapter = self._adapters.get(adapter_name)
if adapter is None:
raise ChatError(f'Adapter "{adapter_name}" not found for channel ID "{channel_id}"')
registered = sorted(self._adapters.keys())
raise ChatError(
f'Adapter "{adapter_name}" not found for channel ID "{channel_id}" '
f"(registered adapters: {registered})"
)
Comment on lines +1504 to +1508

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fix formatter drift in this file before merge.

ruff format --check is failing for src/chat_sdk/chat.py, so CI will stay red until this file is formatted.

Also applies to: 1566-1570

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/chat_sdk/chat.py` around lines 1504 - 1508, Formatting drift in
src/chat_sdk/chat.py causes CI to fail; run the project formatter to fix
whitespace/line-wrapping so `ruff format --check` passes. Reformat the file (or
run `ruff format` on the repository) and ensure the blocks around the ChatError
raise (references: ChatError, adapter_name, channel_id, self._adapters) and the
similar block later are normalized to the project's style so the string
concatenation/line breaks match the formatter expectations. After formatting,
re-run the linter/format check to confirm the drift is resolved.

Comment on lines 1503 to +1508

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic for raising an error when an adapter is not found is duplicated in the thread method. To improve maintainability and avoid code duplication, consider extracting this into a private helper method. You will also need to import NoReturn from typing.

Suggested change
if adapter is None:
raise ChatError(f'Adapter "{adapter_name}" not found for channel ID "{channel_id}"')
registered = sorted(self._adapters.keys())
raise ChatError(
f'Adapter "{adapter_name}" not found for channel ID "{channel_id}" '
f"(registered adapters: {registered})"
)
if adapter is None:
self._raise_adapter_not_found(adapter_name, "channel", channel_id)

return ChannelImpl(
_ChannelImplConfigWithAdapter(
id=channel_id,
Expand Down Expand Up @@ -1559,7 +1563,11 @@ def thread(

adapter = self._adapters.get(adapter_name)
if adapter is None:
raise ChatError(f'Adapter "{adapter_name}" not found for thread ID "{thread_id}"')
registered = sorted(self._adapters.keys())
raise ChatError(
f'Adapter "{adapter_name}" not found for thread ID "{thread_id}" '
f"(registered adapters: {registered})"
)
Comment on lines 1565 to +1570

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As mentioned in my other comment, you can use the new _raise_adapter_not_found helper method here to reduce code duplication.

Suggested change
if adapter is None:
raise ChatError(f'Adapter "{adapter_name}" not found for thread ID "{thread_id}"')
registered = sorted(self._adapters.keys())
raise ChatError(
f'Adapter "{adapter_name}" not found for thread ID "{thread_id}" '
f"(registered adapters: {registered})"
)
if adapter is None:
self._raise_adapter_not_found(adapter_name, "thread", thread_id)


# Defer to the adapter to derive channel_id as a secondary sanity
# check — some platform-specific patterns can pass the structural
Expand Down
Loading