From f4e1240885c82139a6142e31818139eef48f8545 Mon Sep 17 00:00:00 2001 From: JasonWildMe Date: Wed, 29 Jul 2026 16:02:48 -0700 Subject: [PATCH] Fix silent no-op deep reindex for new individuals in assignFromIAAPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #1547 (GH-1514). The post-commit queueIndividualsByIdForDeepReindex call in IBEISIA.assignFromIAAPI queued the raw "name" request parameter. When assignFromIA / assignFromIANoCreation creates a new MarkedIndividual, the name is only registered via addName(); the individualID is a generated UUID. The helper resolves ids via getMarkedIndividualQuiet (a primary-key lookup), so for newly created individuals the queue call silently resolved nothing and their encounters kept stale denormalized fields (individualNumberEncounters etc.) in OpenSearch. Queue the datastore individualID instead, taken from the newMarkedIndividual returned by the assign call — the same fix #1547 applied in EncounterVMData, ImportIA, and AnnotationEdit. Co-Authored-By: Claude Fable 5 --- src/main/java/org/ecocean/identity/IBEISIA.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/ecocean/identity/IBEISIA.java b/src/main/java/org/ecocean/identity/IBEISIA.java index 4a10d29342..ca30c2565d 100644 --- a/src/main/java/org/ecocean/identity/IBEISIA.java +++ b/src/main/java/org/ecocean/identity/IBEISIA.java @@ -2613,10 +2613,16 @@ public static JSONObject assignFromIAAPI(JSONObject arg, Shepherd myShepherd, bo res = assignFromIA(indivId, al, myShepherd); } rtn.put("success", true); + // GH-1514: id to queue for post-commit deep reindex below. When a new + // individual was created, indivId is a *name*, not the generated + // individualID, and would silently fail to resolve in + // queueIndividualsByIdForDeepReindex. + String reindexIndividualId = indivId; if (res.get("newMarkedIndividual") != null) { MarkedIndividual ind = (MarkedIndividual)res.get("newMarkedIndividual"); myShepherd.getPM().makePersistent(ind); rtn.put("newMarkedIndividual", ind.getIndividualID()); + reindexIndividualId = ind.getIndividualID(); } if (res.get("encounters") != null) { JSONArray je = new JSONArray(); @@ -2639,7 +2645,7 @@ public static JSONObject assignFromIAAPI(JSONObject arg, Shepherd myShepherd, bo // GH-1514: post-commit, queue deep reindex of the target individual so // sibling encounters pick up refreshed individualNumberEncounters etc. org.ecocean.IndexingManager.queueIndividualsByIdForDeepReindex(myShepherd, - java.util.Collections.singleton(indivId)); + java.util.Collections.singleton(reindexIndividualId)); return rtn; }