fix(comment): declare missing @PathVariable params on block comment endpoints
Some checks failed
CI / Unit & Component Tests (push) Failing after 3m58s
CI / OCR Service Tests (push) Successful in 49s
CI / Backend Unit Tests (push) Failing after 3m19s
CI / Unit & Component Tests (pull_request) Failing after 3m58s
CI / OCR Service Tests (pull_request) Successful in 46s
CI / Backend Unit Tests (pull_request) Failing after 3m25s
Some checks failed
CI / Unit & Component Tests (push) Failing after 3m58s
CI / OCR Service Tests (push) Successful in 49s
CI / Backend Unit Tests (push) Failing after 3m19s
CI / Unit & Component Tests (pull_request) Failing after 3m58s
CI / OCR Service Tests (pull_request) Successful in 46s
CI / Backend Unit Tests (pull_request) Failing after 3m25s
getBlockComments was missing documentId; replyToBlockComment was missing blockId. Spring silently ignored undeclared path variables — the segments were parsed but never bound. Now both parameters are explicitly declared so Spring rejects non-UUID values with 400. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,9 @@ public class CommentController {
|
|||||||
// ─── Block (transcription) comments ────────────────────────────────────────
|
// ─── Block (transcription) comments ────────────────────────────────────────
|
||||||
|
|
||||||
@GetMapping("/api/documents/{documentId}/transcription-blocks/{blockId}/comments")
|
@GetMapping("/api/documents/{documentId}/transcription-blocks/{blockId}/comments")
|
||||||
public List<DocumentComment> getBlockComments(@PathVariable UUID blockId) {
|
public List<DocumentComment> getBlockComments(
|
||||||
|
@PathVariable UUID documentId,
|
||||||
|
@PathVariable UUID blockId) {
|
||||||
return commentService.getCommentsForBlock(blockId);
|
return commentService.getCommentsForBlock(blockId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ public class CommentController {
|
|||||||
@RequirePermission({Permission.ANNOTATE_ALL, Permission.WRITE_ALL})
|
@RequirePermission({Permission.ANNOTATE_ALL, Permission.WRITE_ALL})
|
||||||
public DocumentComment replyToBlockComment(
|
public DocumentComment replyToBlockComment(
|
||||||
@PathVariable UUID documentId,
|
@PathVariable UUID documentId,
|
||||||
|
@PathVariable UUID blockId,
|
||||||
@PathVariable UUID commentId,
|
@PathVariable UUID commentId,
|
||||||
@RequestBody CreateCommentDTO dto,
|
@RequestBody CreateCommentDTO dto,
|
||||||
Authentication authentication) {
|
Authentication authentication) {
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ class CommentControllerTest {
|
|||||||
|
|
||||||
// ─── Block comment endpoints ─────────────────────────────────────────────
|
// ─── Block comment endpoints ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser
|
||||||
|
void getBlockComments_returns400_when_documentId_is_not_a_UUID() throws Exception {
|
||||||
|
UUID blockId = UUID.randomUUID();
|
||||||
|
mockMvc.perform(get("/api/documents/NOT-A-UUID/transcription-blocks/" + blockId + "/comments"))
|
||||||
|
.andExpect(status().isBadRequest());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithMockUser
|
@WithMockUser
|
||||||
void getBlockComments_returns200() throws Exception {
|
void getBlockComments_returns200() throws Exception {
|
||||||
@@ -115,6 +123,15 @@ class CommentControllerTest {
|
|||||||
|
|
||||||
// ─── Block reply endpoints ───────────────────────────────────────────────
|
// ─── Block reply endpoints ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@WithMockUser(authorities = "ANNOTATE_ALL")
|
||||||
|
void replyToBlockComment_returns400_when_blockId_is_not_a_UUID() throws Exception {
|
||||||
|
mockMvc.perform(post("/api/documents/" + DOC_ID + "/transcription-blocks/NOT-A-UUID"
|
||||||
|
+ "/comments/" + COMMENT_ID + "/replies")
|
||||||
|
.contentType(MediaType.APPLICATION_JSON).content(COMMENT_JSON))
|
||||||
|
.andExpect(status().isBadRequest());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void replyToBlockComment_returns401_whenUnauthenticated() throws Exception {
|
void replyToBlockComment_returns401_whenUnauthenticated() throws Exception {
|
||||||
UUID blockId = UUID.randomUUID();
|
UUID blockId = UUID.randomUUID();
|
||||||
|
|||||||
Reference in New Issue
Block a user