Skip to content

[Fix] MCP get_document_detail이 삭제된 문서를 걸러내지 않던 문제 수정 #291

Description

@kangcheolung

📌 Description

DocGridMcpTools.getDocumentDetail()(backend/src/main/java/com/opensource/docgrid/domain/mcp/tool/DocGridMcpTools.java)이
document.getStatus() == DocumentStatus.DELETED 여부를 확인하지 않아, 소프트 삭제된 문서도
정상 문서처럼 상세 정보(제목·현재버전·상태·수정시각)를 그대로 반환한다.

🔍 문제 상황

같은 도메인 안에서 조회 경로별로 DELETED 처리가 비대칭이다.

조회 경로 DELETED 체크
get_document_detail (MCP) ❌ 없음
get_indexing_status (MCP → DocumentQueryService.getDocumentStatus()) ✅ 있음
REST /api/documents/{id} (DocumentQueryService.getReadableDocument()) ✅ 있음

재현 절차(예상)

  1. 문서 업로드 → documentId 확보
  2. 해당 문서 삭제(소프트 삭제, statusDELETED로 전이)
  3. get_indexing_status(documentId) 호출 → DOCUMENT_NOT_FOUND (정상)
  4. get_document_detail(documentId) 호출 → 정상 응답이 나옴 (버그)

왜 지금까지 안 걸렸는지: DocGridMcpToolsTest에 DELETED 케이스 테스트가 없음(정상/documentId누락/권한없음/문서없음/미인증 5종만 존재).

✅ To-do

  • getDocumentDetail()에 DELETED 체크 추가 (DocumentQueryService.getReadableDocument()와 동일 패턴)
  • DocGridMcpToolsTest에 DELETED 케이스 단위 테스트 추가
  • 로컬 서버 기동 후 MCP 토큰 발급 → Claude에 연동해 실제 삭제 문서로 재현·수정 확인

✅ 완료 기준

  • 삭제된 문서를 get_document_detail로 조회하면 DOCUMENT_NOT_FOUND가 반환된다.
  • get_indexing_status와 동일한 동작을 보인다.
  • ./backend/gradlew -p backend test 전체 통과.

📒 기타

  • 원래 이슈 로드맵(#93~#127) 이후, hotfix/comment-cleanup 브랜치에서 코드 리뷰 중 발견.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions