fix(api): guard face-thumbnail URL when no derived_asset exists #642

Merged
chris merged 2 commits from fix/people-thumbnail-404 into main 2026-07-18 22:55:42 +02:00
Owner

Summary

People browse page showed 404 errors for all face-crop thumbnails.

Root cause: ClassInstanceService.enrichPeopleFaces() built face-thumbnail URLs unconditionally even when no face_thumbnail derived_asset existed. The auto_selected CTE (line 367) picked rn=1 face without checking face_thumbnail_key IS NOT NULL — inconsistency with manual_selected CTE (line 362) which was already guarded.

Fix: Add AND rf.face_thumbnail_key IS NOT NULL filter to auto_selected CTE. When no face has a thumbnail, re becomes null → falls back to gi.representativeThumbnailUrl() (generic media thumbnail, always safe).

Changes

  • apps/api/src/main/java/dev/memories/api/discovery/ClassInstanceService.java — 1 line: AND rf.face_thumbnail_key IS NOT NULL
  • apps/api/src/test/java/dev/memories/api/discovery/ClassInstanceServiceTest.java — 3 regression tests
  • apps/api/src/test/java/dev/memories/api/discovery/H2FaceBoxAreaFunction.java — H2 stub for face_box_area PG function

Test Results

  • 91/91 tests pass in :apps:api:test
  • 3 new regression tests:
    • personWithFaceThumbnailReturnsFaceUrl — happy path
    • personWithoutFaceThumbnailReturnsNullPreviewUrl — bug repro
    • personWithMixedFacesPicksFaceWithThumbnail — mixed scenario

Frontend

No changes needed. PeopleBrowser.svelte:666 and DiscoveryDomainInstances.svelte:141-156 already handle null representativePreviewUrl with "No preview" fallback.

Audit

Sibling bug audit: no other ROW_NUMBER CTEs in same bug class. CollaborativeClassInstancePeopleBridge already guarded. personSummary() already guarded. ClassInstanceAutomationRunService is different context (face creation, not browse).

Version

v1.21.6 → v1.21.7

## Summary People browse page showed 404 errors for all face-crop thumbnails. **Root cause:** `ClassInstanceService.enrichPeopleFaces()` built face-thumbnail URLs unconditionally even when no `face_thumbnail` derived_asset existed. The `auto_selected` CTE (line 367) picked `rn=1` face without checking `face_thumbnail_key IS NOT NULL` — inconsistency with `manual_selected` CTE (line 362) which was already guarded. **Fix:** Add `AND rf.face_thumbnail_key IS NOT NULL` filter to `auto_selected` CTE. When no face has a thumbnail, `re` becomes null → falls back to `gi.representativeThumbnailUrl()` (generic media thumbnail, always safe). ## Changes - `apps/api/src/main/java/dev/memories/api/discovery/ClassInstanceService.java` — 1 line: `AND rf.face_thumbnail_key IS NOT NULL` - `apps/api/src/test/java/dev/memories/api/discovery/ClassInstanceServiceTest.java` — 3 regression tests - `apps/api/src/test/java/dev/memories/api/discovery/H2FaceBoxAreaFunction.java` — H2 stub for `face_box_area` PG function ## Test Results - 91/91 tests pass in `:apps:api:test` - 3 new regression tests: - `personWithFaceThumbnailReturnsFaceUrl` — happy path - `personWithoutFaceThumbnailReturnsNullPreviewUrl` — bug repro - `personWithMixedFacesPicksFaceWithThumbnail` — mixed scenario ## Frontend No changes needed. `PeopleBrowser.svelte:666` and `DiscoveryDomainInstances.svelte:141-156` already handle null `representativePreviewUrl` with "No preview" fallback. ## Audit Sibling bug audit: no other ROW_NUMBER CTEs in same bug class. `CollaborativeClassInstancePeopleBridge` already guarded. `personSummary()` already guarded. `ClassInstanceAutomationRunService` is different context (face creation, not browse). ## Version v1.21.6 → v1.21.7
fix(api): guard face-thumbnail URL when no derived_asset exists
All checks were successful
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 / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (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 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 / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 6m34s
551c5bd7af
auto_selected CTE now requires face_thumbnail_key IS NOT NULL, matching
manual_selected. When no face has a thumbnail, the enrichment returns
no representative row, falling back to the generic media thumbnail URL
instead of constructing a face URL that 404s.

Added regression tests for people with/without face thumbnails.
chore: bump version 1.21.6 → 1.21.7
All checks were successful
Build and Deploy / Detect changed services and test scopes (push) Successful in 6s
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 / Build plants worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build converter worker image (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 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 / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 3m18s
59272ee5b2
chris merged commit 84bf80ee15 into main 2026-07-18 22:55:42 +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!642
No description provided.