Skip to content

feat(adapters): log init for gchat + github, include registered adapters in not-found error#96

Closed
tony-chinchill-ai wants to merge 1 commit into
Chinchill-AI:mainfrom
tony-chinchill-ai:tony/adapter-init-logs-and-not-found-context
Closed

feat(adapters): log init for gchat + github, include registered adapters in not-found error#96
tony-chinchill-ai wants to merge 1 commit into
Chinchill-AI:mainfrom
tony-chinchill-ai:tony/adapter-init-logs-and-not-found-context

Conversation

@tony-chinchill-ai
Copy link
Copy Markdown
Contributor

@tony-chinchill-ai tony-chinchill-ai commented May 20, 2026

Summary

  • GoogleChatAdapter.initialize() now logs Google Chat adapter initialized matching the existing Slack/Teams pattern. Today only Slack and Teams emit per-adapter init lines; gchat and GitHub are silent, so operators can't see at a glance whether each adapter actually came up.
  • GitHubAdapter.initialize() now logs GitHub adapter initialized unconditionally. The existing GitHub auth completed log only fires when _auth_token is set and the user-info fetch succeeds, so multi-tenant deployments (which use App credentials, not _auth_token) had no init signal.
  • Chat.channel() and Chat.thread() not-found errors now append (registered adapters: [...]) so operators can disambiguate "the adapter was never constructed in this process" from "constructed but the lookup name is wrong".

Why now

Driven by a chinchill-api incident on 2026-05-19: a DBOS worker hit Adapter "github" not found for thread ID "github:tony-chinchill-ai/test:issue:1" with no other diagnostic context. With these changes the same error becomes Adapter "github" not found for thread ID "github:..." (registered adapters: ['slack', 'teams']), immediately pointing at the GitHub-adapter construction path rather than the lookup path.

Test plan

  • pytest (no behavioral changes; only added log calls + error-message string).
  • Manual: in a deployment that registers gchat + github, restart and confirm stderr contains both [gchat] Google Chat adapter initialized and [github] GitHub adapter initialized lines.
  • Manual: trigger an Adapter not found error and confirm the registered-adapter list appears in the message.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added initialization logs for GitHub and Google Chat adapters.
    • Enhanced error messages for invalid channel and thread IDs to display available adapters.

Review Change Stack

…ers in not-found error

- GoogleChatAdapter.initialize() now logs "Google Chat adapter initialized" matching the Slack/Teams pattern.
- GitHubAdapter.initialize() now logs "GitHub adapter initialized" unconditionally (the existing "GitHub auth completed" was conditional on auth_token validation).
- Chat.channel() / Chat.thread() not-found errors now append "(registered adapters: [...])" so operators can tell at a glance whether the lookup failed because the adapter was never constructed in this process vs. constructed but skipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

📝 Walkthrough

Walkthrough

This PR adds initialization logging to two chat adapters and enhances error diagnostics. GitHub and Google Chat adapters now emit info logs when initialization completes. Meanwhile, channel and thread lookup methods include registered adapter names in their error messages when an adapter is not found, aiding troubleshooting.

Changes

Logging and Error Message Improvements

Layer / File(s) Summary
Adapter initialization logging
src/chat_sdk/adapters/github/adapter.py, src/chat_sdk/adapters/google_chat/adapter.py
GitHub and Google Chat adapters now log informational messages upon initialize completion, after bot user ID setup finishes.
Enhanced channel/thread error messages
src/chat_sdk/chat.py
Chat.channel() and Chat.thread() error paths now include a sorted list of registered adapter names in ChatError messages when adapter lookup fails.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Two adapters now announce their start,
While errors speak the adapters' part.
From GitHub calls to Google's chats so bright,
Initialization logs shine the light! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main changes: adding initialization logging for two adapters and enriching not-found error messages with registered adapter context.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with 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.

Inline comments:
In `@src/chat_sdk/chat.py`:
- Around line 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.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b8ca5f8f-9f9f-450b-8f7b-80e654fafc24

📥 Commits

Reviewing files that changed from the base of the PR and between 08c42fa and a298c2f.

📒 Files selected for processing (3)
  • src/chat_sdk/adapters/github/adapter.py
  • src/chat_sdk/adapters/google_chat/adapter.py
  • src/chat_sdk/chat.py

Comment thread src/chat_sdk/chat.py
Comment on lines +1504 to +1508
registered = sorted(self._adapters.keys())
raise ChatError(
f'Adapter "{adapter_name}" not found for channel ID "{channel_id}" '
f"(registered adapters: {registered})"
)
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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds initialization logs to the GitHub and Google Chat adapters and enhances error messages in the channel and thread methods of chat.py by listing all registered adapters when a lookup fails. The reviewer suggested refactoring the duplicated error-raising logic into a private helper method to improve maintainability and reduce code duplication.

Comment thread src/chat_sdk/chat.py
Comment on lines 1503 to +1508
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})"
)
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)

Comment thread src/chat_sdk/chat.py
Comment on lines 1565 to +1570
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})"
)
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)

Copy link
Copy Markdown
Collaborator

Replaced by #104 (could not push merge-conflict resolution to the fork branch from an automated session). All original commits preserved in #104's branch history; @tony-chinchill-ai credited.


Generated by Claude Code

patrick-chinchill added a commit that referenced this pull request May 28, 2026
…ers in not-found error (#104)

Operator-observability improvements driven by a 2026-05-19 chinchill-api incident.

- GoogleChatAdapter.initialize() now logs "Google Chat adapter initialized" matching Slack/Teams
- GitHubAdapter.initialize() now logs "GitHub adapter initialized" unconditionally — the existing "GitHub auth completed" log only fires when _auth_token is set, so App-credential deployments had no init signal
- Chat.channel() and Chat.thread() not-found errors now append "(registered adapters: [...])" so operators can disambiguate "adapter never constructed in this process" from "constructed but lookup name wrong"

Original authorship: @tony-chinchill-ai (commit a298c2f preserved in merge history). Replaces #96 after conflict resolution with #90's chat.get_user method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants