Skip to content

fix(#123): コメントの note_id 検証を追加し REST 階層整合性を修正する#136

Merged
hideyukiMORI merged 1 commit into
mainfrom
fix/123-comment-note-id-validation
May 19, 2026
Merged

fix(#123): コメントの note_id 検証を追加し REST 階層整合性を修正する#136
hideyukiMORI merged 1 commit into
mainfrom
fix/123-comment-note-id-validation

Conversation

@hideyukiMORI
Copy link
Copy Markdown
Owner

Summary

  • GetCommentUseCase.executecomment_id: int を直接受け取っていたのを GetCommentInput 型 DTO に変更
  • CreateCommentUseCaseNoteRepositoryInterface を追加し、存在しないノートへのコメント作成を 404 に
  • get_comment / update_comment / delete_comment ハンドラーで comment.note_id != note_id の場合 404
  • mcp.pyGetCommentInput を使用するよう更新
  • HTTP テストをノート事前作成パターンに更新し、クロスノートアクセスのテストを追加

Test plan

  • 全既存 comment テスト継続パス
  • test_create_raises_when_note_not_found — 存在しないノートへのコメント作成が NoteNotFoundException(新規)
  • test_create_comment_for_nonexistent_note_returns_404 — HTTP レベルで 404(新規)
  • test_get_comment_from_wrong_note_returns_404 — 異なるノード URL からのアクセスが 404(新規)

Closes #123

🤖 Generated with Claude Code

- GetCommentInput 型付き DTO を追加し GetCommentUseCase を更新
- CreateCommentUseCase が NoteRepository でノート存在を確認し、なければ 404
- get/update/delete ハンドラーで comment.note_id != path note_id の場合 404
- 存在しないノートへのコメント作成・異なるノート URL からのアクセスを防止

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hideyukiMORI hideyukiMORI merged commit c720a83 into main May 19, 2026
1 check failed
@hideyukiMORI hideyukiMORI deleted the fix/123-comment-note-id-validation branch May 21, 2026 15:08
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.

schema.py: comments.note_id に外部キー制約がなく孤児レコードが発生する

1 participant