Fix faceAnnotationId LIKE patterns in occurrence_refs joins (4 locations) #696

Closed
opened 2026-07-22 18:02:26 +02:00 by chris · 0 comments
Owner

Summary

4 remaining occurrence_refs LIKE joins use faceAnnotationId in the pattern — same root cause as PR #695 but in different code paths (discovery/auto-approval, not retrospective retarget).

Affected Locations

  • ClassInstanceService.java:3961 — tentativeAssignments discovery path
  • ClassInstanceService.java:4428 — acceptGenericNamedCandidate
  • ClassInstanceDiscoveryService.java:753 — discovery candidate matching
  • DiscoveryService.java:501 — discovery candidate matching

Root Cause

Same as PR #695: occurrence_refs for face_detection candidates contains [{"mediaItemId":"..."}], not faceAnnotationId. The LIKE join pattern `LIKE '%' || faceAnnotationId || '%'` never matches.

Fix

Replace with the same pattern from PR #695:

AND dr.media_item_id = CAST(media_item_id_from_occurrence_refs(cic.occurrence_refs) AS UUID)

The PG function media_item_id_from_occurrence_refs() is already available (V120 migration).

Context

  • Found during PR #695 review by Test Engineer
  • Sibling issue to #695 — different code paths, same LIKE-vs-JSONB bug
  • Lower priority than #695 (these are discovery/auto-approval paths, not the primary retrospective retarget)
## Summary 4 remaining `occurrence_refs` LIKE joins use `faceAnnotationId` in the pattern — same root cause as PR #695 but in different code paths (discovery/auto-approval, not retrospective retarget). ## Affected Locations - `ClassInstanceService.java:3961` — tentativeAssignments discovery path - `ClassInstanceService.java:4428` — acceptGenericNamedCandidate - `ClassInstanceDiscoveryService.java:753` — discovery candidate matching - `DiscoveryService.java:501` — discovery candidate matching ## Root Cause Same as PR #695: `occurrence_refs` for face_detection candidates contains `[{"mediaItemId":"..."}]`, not `faceAnnotationId`. The LIKE join pattern \`LIKE '%' || faceAnnotationId || '%'\` never matches. ## Fix Replace with the same pattern from PR #695: ```sql AND dr.media_item_id = CAST(media_item_id_from_occurrence_refs(cic.occurrence_refs) AS UUID) ``` The PG function `media_item_id_from_occurrence_refs()` is already available (V120 migration). ## Context - Found during PR #695 review by Test Engineer - Sibling issue to #695 — different code paths, same LIKE-vs-JSONB bug - Lower priority than #695 (these are discovery/auto-approval paths, not the primary retrospective retarget)
chris closed this issue 2026-07-22 18:54:48 +02:00
Sign in to join this conversation.
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#696
No description provided.