fix(api): unknown upload-session ids answer 404 instead of 500 #1340
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/api-session-404"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Unknown upload-session ids previously produced HTTP 500 on GET /api/upload-sessions/{id}, POST …/files (receive) and POST …/commit, because
UploadSessionService.requireOwnership(and the session-status loads in UploadReceiveService/UploadCommitService) did a JdbcClient.single()/singleRow()whoseEmptyResultDataAccessExceptionApiExceptionHandler does not map.Fix: normalize only the upload-session lookups to
NoSuchElementException→ 404 ProblemDetail (no global EmptyResultDataAccessException mapping; SEC-4 403-not-owner semantics untouched).Verified:
rtk ./gradlew :apps:api:testsubsets upload + web + contracts — 0 failures.Motivation: Android client recovery probing stale sessions needs a clean 404 (part of the Android upload-reliability fix set; see also engine PR + #1339).
requireOwnership/get and the receive/commit session-status loads did JdbcClient singleRow()/single() lookups whose EmptyResultDataAccessException ApiExceptionHandler does not map, so GET /api/upload-sessions/{id}, file receive and commit answered HTTP 500 for unknown session ids. Normalize only the upload-session lookups to NoSuchElementException, which the existing handler maps to a 404 ProblemDetail (same pattern as UploadActivityService.cancel). No global EmptyResultDataAccessException mapping; SEC-4 403-not-owner semantics and TTL untouched. Tests: MockMvc endpoint tests for GET/receive/commit 404 ProblemDetail, unknown-id ownership test now expects NoSuchElementException. KNOWN_ISSUES: ISSUE-176.