Skip to content

fix: conversations.infoのエラーログ追加とチャンネル名キャッシュ#22

Merged
eai04191 merged 8 commits into
mainfrom
fix/message-handler-logging
Apr 2, 2026
Merged

fix: conversations.infoのエラーログ追加とチャンネル名キャッシュ#22
eai04191 merged 8 commits into
mainfrom
fix/message-handler-logging

Conversation

@eai04191
Copy link
Copy Markdown
Member

@eai04191 eai04191 commented Apr 2, 2026

issue

なし(運用中に発見した転送失敗の調査対応)

変更内容

  • conversations.infoが例外をスローした場合にtry-catchでエラー内容(name/message/stack)をログ出力するようにした
  • 同一チャンネルへの重複API呼び出しを避けるためチャンネル名のキャッシュを追加した(createMessageHandler内のクロージャ)
  • ハンドラー全体のログを改善し、スキップ理由を明示するようにした
  • キャッシュと例外時の挙動のテストを追加した

確認したこと

  • npm run typecheckで新規型エラーなし
  • npm testで既存テスト通過(env.test.tsの失敗は既存)

補足事項

CloudWatchログで動画投稿が転送されないケースを確認。conversations.infoが例外をスローしていたが、try-catchがなくBoltに飲まれて原因不明だった。ログ改善をデプロイし、エラー内容を特定してから対策を決める。

PR時のセルフチェック

  • 関数や変数の命名は一目で分かるものになってますか?
  • コメントは適切な量で、誰が見ても分かるコメントになってますか?
  • PR内容に関するテストは書きましたか?
  • PR内容に付随する各種ドキュメントは一緒に修正しましたか?
  • IssueをCloseする場合、完了の定義は満たせていますか?

by Claude Code Badge

conversations.infoが例外をスローした場合にBoltに飲まれて原因不明だった問題に対応。
try-catchでエラー内容をログ出力するようにした。
また、同一チャンネルへの重複API呼び出しを避けるためキャッシュを追加した。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 2, 2026 03:33
一時的なSlack APIエラーで転送が失敗するケースに対応。
500ms間隔で最大2回リトライし、自動回復を試みる。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

運用中に発生した転送失敗の原因特定を進めやすくするため、Slack conversations.info 周りのログ強化と、チャンネル名取得の重複 API 呼び出し削減(キャッシュ)を導入するPRです。

Changes:

  • conversations.info 呼び出しを getChannelName に集約し、例外時のエラーログを追加
  • チャンネルID→チャンネル名のキャッシュ(Map)を追加して重複呼び出しを抑制
  • ハンドラーのログを構造化し、スキップ理由を明確化

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/handlers/message.ts Outdated
Comment thread src/handlers/message.ts Outdated
Comment thread src/handlers/message.ts
eai04191 and others added 4 commits April 2, 2026 12:46
モジュールスコープで無制限に増え続ける問題を解消するため、
ハンドラーのファクトリ関数内に閉じ込めた。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
error.messageだけではエラー種別やスタックトレースが失われるため、
name, message, stackをすべて出力するようにした。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
同一チャンネルでconversations.infoが1回だけ呼ばれること、
例外時にchat.postMessageが呼ばれないことを検証するテストを追加した。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 2, 2026 03:50
getChannelName呼び出しの引数を複数行に展開した。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/handlers/__tests__/message.test.ts
describeスコープで共有していたhandlerを各itブロック内で
createMessageHandlerから生成するように変更し、
テスト間のキャッシュ状態の依存を排除した。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@eai04191 eai04191 merged commit 66c20c5 into main Apr 2, 2026
3 checks passed
@eai04191 eai04191 deleted the fix/message-handler-logging branch April 2, 2026 03:58
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