fix(api): unknown upload-session ids answer 404 instead of 500 #1340

Merged
chris merged 1 commit from fix/api-session-404 into main 2026-10-23 21:59:57 +02:00
Owner

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() whose EmptyResultDataAccessException ApiExceptionHandler 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).

  • 3 new MockMvc endpoint tests (GET/receive/commit → 404 + ProblemDetail)
  • existing unknown-session test updated
  • KNOWN_ISSUES.md: ISSUE-176 appended

Verified: rtk ./gradlew :apps:api:test subsets 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).

## 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()` whose `EmptyResultDataAccessException` ApiExceptionHandler 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). - 3 new MockMvc endpoint tests (GET/receive/commit → 404 + ProblemDetail) - existing unknown-session test updated - KNOWN_ISSUES.md: ISSUE-176 appended Verified: `rtk ./gradlew :apps:api:test` subsets 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).
fix(api): unknown upload-session ids answer 404 instead of 500
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Deploy review instance (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 9m53s
e660ebf5fd
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.
chris merged commit dc3ba3aec8 into main 2026-10-23 21:59:57 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1340
No description provided.