fix: release 通知の本文を取得できるようにする - #125
Merged
Merged
Conversation
Release の通知だけ本文が出ていなかった(issue #121)。原因は 2 つある。 ひとつは投稿者のキーの違い。GitHub の Release オブジェクトは投稿者を author に 入れるが、Github::Comment は user を必須にしていた。そのため Release の応答は JSON の解析ごと失敗し、find_comment_by_url の rescue に落ちて本文が 「(本文を取得できませんでした)」に置き換わっていた。user と author の どちらも nilable で受け、表示に使う投稿者は poster にまとめる。 もうひとつは本文取得先の判定。BODY_TYPES に Release が無いため、通知に latest_comment_url が入らない場合は comment_url が空になり、本文を取りに 行かなくなっていた。Release も subject.url を取得すればリリースノートが 返るので、BODY_TYPES に加える。 色は変えていない。Release は従来どおり既定色のままにする。 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SmoDC7XRgDx1AcWumgv3Uq
limit7412
marked this pull request as ready for review
August 29, 2026 08:01
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
issue #121 の対応。
原因
Release の通知だけ本文が出ていなかった。
調べたところ原因は 2 つあった。
投稿者のキーが user ではなく author
GitHub の Release オブジェクトは投稿者を
authorに入れる。一方
Github::Commentはgetter user : Userと必須にしていたため、Release の応答は JSON の解析ごと失敗していた。find_comment_by_urlは解析失敗を rescue してComment.new COMMENT_FETCH_FAILEDを返すので、本文が丸ごと「(本文を取得できませんでした)」に置き換わる。手元で実際の Release オブジェクトの形を流したところ、
Missing JSON attribute: userで落ちることを確認した。BODY_TYPES に Release が無い
comment_urlはlatest_comment_urlが空のとき、BODY_TYPESに含まれる type だけsubject.urlにフォールバックする。Release は含まれていないので、通知に
latest_comment_urlが入らない場合は空文字になり、本文を取りに行かない。修正
userとauthorのどちらも nilable で受け、表示に使う投稿者をposterにまとめた。どちらのキーも無い応答では空の
Userを返すので、名前もアイコンも付けずに本文だけが出る。Subject::TypeにRELEASEを足し、BODY_TYPESに加えた。Release は
subject.urlを取得すればリリースノートが返るため、latest_comment_urlの有無にかかわらず本文を出せる。呼び出し側は
Github::Usecase#build_messageの 3 行(comment.user.*→comment.poster.*)だけ。変えていないもの
#colorは Release に個別の色を持たないが、これは本文とは別の話なので触っていないUPDATE_TYPES/update?も変えていない。update?は現状 spec からしか参照されておらず、Release を含めるかは本文の取得と関係しないNUMBERED_TYPESにも入れていない。Release のsubject.url末尾は数値のリリース ID で、#123と出すと誤解を招く(既存コメントの判断のまま)テスト
crystal specは 130 examples, 0 failures。追加したのは以下。spec/github/models_spec.crlatest_comment_urlが空の Release でcomment_urlがsubject.urlになることuserとauthorの両方があればuserを優先することUserに倒れることspec/github/usecase_spec.cr修正前の実装(
user必須、BODY_TYPESに Release 無し)に戻すと、このうち 4 件が落ちることを確認した。検証環境について
これまでと同じく、ネットワーク制限により Crystal 1.21.0 を用意できず Ubuntu の 1.11.2 で検証している。
crystal tool formatは 1.11 と 1.21 で複数行引数の末尾カンマの扱いが違いリポジトリ全体に差分を出すため実行せず、変更した 4 ファイルを個別に確認した。ameba は 1.11 でビルドできないためローカル実行できていない。
Closes #121
Generated by Claude Code