[feat] 배달팟 참여자 목록 조회 API 구현#99
Conversation
📝 WalkthroughWalkthroughAdds an authenticated party-participant listing API, response DTOs, service retrieval and role mapping, explicit security rules, and a dedicated unauthorized response for participant-list requests. ChangesParty participant listing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant DeliveryPartyController
participant DeliveryPartyService
participant PartyParticipantRepository
participant UserRepository
Client->>DeliveryPartyController: GET /api/v1/parties/{partyId}/participants
DeliveryPartyController->>DeliveryPartyService: getPartyParticipants(partyId)
DeliveryPartyService->>PartyParticipantRepository: Find JOINED participants
DeliveryPartyService->>UserRepository: Batch-load users
UserRepository-->>DeliveryPartyService: User records
DeliveryPartyService-->>DeliveryPartyController: PartyParticipantListResponse
DeliveryPartyController-->>Client: ApiResponse success
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/com/leets/tdd/global/config/JwtAuthenticationEntryPoint.java`:
- Around line 30-38: Update the request URI check in JwtAuthenticationEntryPoint
to match participant-list routes under both /api/v1/parties and
/api/v1/delivery-parties, while preserving the existing unauthorized JSON
response and Korean login-required message.
In `@src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java`:
- Around line 75-82: The getPartyParticipants endpoint lacks OpenAPI
documentation. Add `@Operation` and `@SecurityRequirement` annotations to document
bearer authentication, and include response documentation for successful
retrieval plus unauthorized and not-found failures, using the controller’s
existing Swagger annotation conventions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 80a58e00-7f59-4c1f-9cc5-9777e377f895
📒 Files selected for processing (8)
src/main/java/com/leets/tdd/global/config/JwtAuthenticationEntryPoint.javasrc/main/java/com/leets/tdd/global/config/SecurityConfig.javasrc/main/java/com/leets/tdd/party/controller/DeliveryPartyController.javasrc/main/java/com/leets/tdd/party/dto/response/PartyParticipantListResponse.javasrc/main/java/com/leets/tdd/party/dto/response/PartyParticipantResponse.javasrc/main/java/com/leets/tdd/party/exception/PartyErrorCode.javasrc/main/java/com/leets/tdd/party/service/DeliveryPartyService.javasrc/test/java/com/leets/tdd/party/service/DeliveryPartyServiceTest.java
| if (request.getRequestURI().matches("/api/v1/parties/[^/]+/participants")) { | ||
| response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); | ||
| response.setContentType(MediaType.APPLICATION_JSON_VALUE); | ||
| response.setCharacterEncoding("UTF-8"); | ||
| response.getWriter().write( | ||
| objectMapper.writeValueAsString(ApiResponse.fail("로그인이 필요합니다.")) | ||
| ); | ||
| return; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate file =="
fd -a 'JwtAuthenticationEntryPoint\.java$' . || true
echo "== locate participant endpoints =="
rg -n 'participants|delivery-parties|parties' src/main/java src/test/java --glob '*java' || true
echo "== git status =="
git status --short || trueRepository: Leets-Official/TDD-BE
Length of output: 8657
🏁 Script executed:
#!/bin/bash
set -euo pipefail
entrypoint=$(fd 'JwtAuthenticationEntryPoint\.java$' . | head -n 1)
echo "== entrypoint: $entrypoint =="
if [ -n "$entrypoint" ]; then
wc -l "$entrypoint"
cat -n "$entrypoint"
fi
echo "== candidate controller files =="
rg -l '`@RequestMapping`|`@GetMapping`|participants|delivery-parties' src/main/java --glob '*java' | head -n 50 || true
echo "== participant mappings outline/text snippets =="
for f in $(rg -l 'participants|delivery-parties' src/main/java --glob '*java' | head -n 20); do
echo "--- $f ---"
wc -l "$f"
rg -n -C 4 'participants|delivery-parties|parties' "$f" || true
done
echo "== regex-only parse verifier from source =="
python3 - <<'PY'
import re, pathlib, sys
entrypoints=list(pathlib.Path('.').rglob('JwtAuthenticationEntryPoint.java'))
for p in entrypoints:
text=p.read_text()
m=re.search(r'request\.getRequestURI\(\)\.matches\("([^"]+)"\)', text)
print(f"{p}: {m.group(1) if m else 'no route regex'}")
if m:
pattern=m.group(1)
for path in [
"/api/v1/parties/abc123/participants",
"/api/v1/delivery-parties/abc123/participants",
"/api/v1/parties/abc123",
]:
print(f" {path} -> {re.fullmatch(pattern, path)}")
PYRepository: Leets-Official/TDD-BE
Length of output: 17286
Handle both registered participant-list routes.
DeliveryPartyController maps {partyId}/participants under both /api/v1/parties and /api/v1/delivery-parties, but this exception handler only matches the former. Missing-token requests to /api/v1/delivery-parties/{partyId}/participants fall through to the generic JWT error response instead of returning “로그인이 필요합니다.”
Proposed fix
- if (request.getRequestURI().matches("/api/v1/parties/[^/]+/participants")) {
+ if (request.getRequestURI().matches(
+ "/api/v1/(?:parties|delivery-parties)/[^/]+/participants"
+ )) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (request.getRequestURI().matches("/api/v1/parties/[^/]+/participants")) { | |
| response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); | |
| response.setContentType(MediaType.APPLICATION_JSON_VALUE); | |
| response.setCharacterEncoding("UTF-8"); | |
| response.getWriter().write( | |
| objectMapper.writeValueAsString(ApiResponse.fail("로그인이 필요합니다.")) | |
| ); | |
| return; | |
| } | |
| if (request.getRequestURI().matches( | |
| "/api/v1/(?:parties|delivery-parties)/[^/]+/participants" | |
| )) { | |
| response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); | |
| response.setContentType(MediaType.APPLICATION_JSON_VALUE); | |
| response.setCharacterEncoding("UTF-8"); | |
| response.getWriter().write( | |
| objectMapper.writeValueAsString(ApiResponse.fail("로그인이 필요합니다.")) | |
| ); | |
| return; | |
| } |
🧰 Tools
🪛 ast-grep (0.44.1)
[warning] 33-35: Avoid writing untrusted input to the HTTP response
Context: response.getWriter().write(
objectMapper.writeValueAsString(ApiResponse.fail("로그인이 필요합니다."))
)
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
(xss-protection-java)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/java/com/leets/tdd/global/config/JwtAuthenticationEntryPoint.java`
around lines 30 - 38, Update the request URI check in
JwtAuthenticationEntryPoint to match participant-list routes under both
/api/v1/parties and /api/v1/delivery-parties, while preserving the existing
unauthorized JSON response and Korean login-required message.
| @GetMapping("/{partyId}/participants") | ||
| public ResponseEntity<ApiResponse<PartyParticipantListResponse>> getPartyParticipants( | ||
| @PathVariable Long partyId, | ||
| @AuthenticationPrincipal UserPrincipal currentUser | ||
| ) { | ||
| PartyParticipantListResponse response = deliveryPartyService.getPartyParticipants(partyId); | ||
| return ResponseEntity.ok(ApiResponse.success("참여자 목록 조회에 성공했습니다.", response)); | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate file =="
fd -a 'DeliveryPartyController.java|DeliveryPartyService.java|.*Swagger.*|.*OpenApi.*|.*ApiDoc.*' . | sed 's#^\./##' | head -h 100
echo "== target controller outline =="
if [ -f src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java ]; then
ast-grep outline src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java || true
echo "== target controller relevant section =="
cat -n src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java | sed -n '1,140p'
else
echo "target file not found"
fi
echo "== swagger annotations around target =="
rg -n "@(Operation|ApiResponse|SecurityIgnore|SecurityScheme|SecurityRequirement|Tag|SecurityAspect|ApiSecurity|Authorization|ErrorResponse|SecurityResponse|SecuritySchema|SecurityResponse|SecurityResponses|SecurityResponse)" src/main/java || true
echo "== global/api docs mentions =="
rg -n "Swagger|OpenAPI|openapi|`@io`\.swagger|`@springdoc`|ApiResponse|SecurityResponse|`@SecurityAnnotation`|`@SecurityResponses`|`@Security`" src/main/java || trueRepository: Leets-Official/TDD-BE
Length of output: 245
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate file =="
fd 'DeliveryPartyController.java|DeliveryPartyService.java|.*Swagger.*|.*OpenApi.*|.*ApiDoc.*' . | sed 's#^\./##' | head -n 150
echo "== target controller outline =="
if [ -f src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java ]; then
ast-grep outline src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java || true
echo "== target controller relevant section =="
cat -n src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java | sed -n '1,140p'
else
echo "target file not found"
fi
echo "== swagger/security annotations around target =="
rg -n "@(Operation|ApiResponse|SecurityIgnore|SecurityScheme|SecurityRequirement|Tag|SecurityAspect|ApiSecurity|Authorization|ErrorResponse|SecurityResponse|SecuritySchema|SecurityResponses|SecurityResponse)" src/main/java || true
echo "== global/api docs mentions =="
rg -n "Swagger|OpenAPI|openapi|`@io`\.swagger|`@springdoc`|ApiResponse|SecurityResponse|`@SecurityAnnotation`|`@SecurityResponses`|`@Security`" src/main/java || trueRepository: Leets-Official/TDD-BE
Length of output: 31350
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== party service outline =="
ast-grep outline src/main/java/com/leets/tdd/party/service/DeliveryPartyService.java || true
echo "== party service getPartyParticipants section =="
cat -n src/main/java/com/leets/tdd/party/service/DeliveryPartyService.java | sed -n '1,220p'
echo "== party controller security annotations =="
cat -n src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java | sed -n '1,120p' | rg -n "@(Operation|ApiResponse|SecurityIgnore|SecurityScheme|SecurityRequirement|Tag|ApiResponse|SecurityResponses|SecurityResponse)" || true
echo "== comparable documented controller sections =="
for f in \
src/main/java/com/leets/tdd/user/controller/UserController.java \
src/main/java/com/leets/tdd/settlement/controller/SettlementController.java \
src/main/java/com/leets/tdd/board/controller/PostController.java
do
if [ -f "$f" ]; then
echo "-- $f --"
rg -n -C 8 "@(Operation|ApiResponse|SecurityRequirement|Tag)" "$f" || true
fi
done
echo "== swagger config =="
cat -n src/main/java/com/leets/tdd/global/config/SwaggerConfig.javaRepository: Leets-Official/TDD-BE
Length of output: 24829
Add Swagger documentation for participants retrieval.
getPartyParticipants exposes participant data and accepts @AuthenticationPrincipal, but the endpoint has no @Operation, @SecurityRequirement, or failure response documentation. Add operation/response docs including the bearer-authenticated success path and unauthorized/not-found failures.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/java/com/leets/tdd/party/controller/DeliveryPartyController.java`
around lines 75 - 82, The getPartyParticipants endpoint lacks OpenAPI
documentation. Add `@Operation` and `@SecurityRequirement` annotations to document
bearer authentication, and include response documentation for successful
retrieval plus unauthorized and not-found failures, using the controller’s
existing Swagger annotation conventions.
작업 내용
변경 사항
리뷰 포인트
체크리스트
Closes #97
Summary by CodeRabbit