Skip to content

Fix silent no-op deep reindex for newly created individuals in assignFromIAAPI - #1704

Open
JasonWildMe wants to merge 1 commit into
mainfrom
fix/assignfromiaapi-deep-reindex-id
Open

Fix silent no-op deep reindex for newly created individuals in assignFromIAAPI#1704
JasonWildMe wants to merge 1 commit into
mainfrom
fix/assignfromiaapi-deep-reindex-id

Conversation

@JasonWildMe

@JasonWildMe JasonWildMe commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #1547 (issue #1514). Fixes the one site where the post-commit deep-reindex added by that PR can still silently no-op.

Summary

IBEISIA.assignFromIAAPI (the IA-driven individual-assignment API used by IAGateway) queues its post-commit deep reindex with the raw name request parameter. When the assign call creates a new MarkedIndividual, that queue entry never resolves, so the new individual and its member encounters keep stale denormalized fields (individualNumberEncounters, first/last encounter dates, etc.) in OpenSearch until something else touches the individual.

Root cause

  • new MarkedIndividual(name, enc) generates a UUID individualID and only registers name via addName() — the name is not the datastore id.
  • IndexingManager.queueIndividualsByIdForDeepReindex resolves ids with Shepherd.getMarkedIndividualQuiet, a strict primary-key lookup that returns null (quietly) for anything that isn't an individualID.
  • So for the new-individual path, the queue call looked up the name, got null, and skipped the reindex — with no log or error.

The existing-individual path was unaffected: there, indivId had already resolved via the same PK lookup inside assignFromIA/assignFromIANoCreation, proving it is a real individualID.

This is the same name-vs-UUID bug class #1547 fixed in EncounterVMData, ImportIA, and AnnotationEdit; this fourth site was missed.

Fix

Both assignFromIA and assignFromIANoCreation already return the newly created individual under the newMarkedIndividual key. Capture its real getIndividualID() there and queue that instead of the raw name parameter. When no new individual was created, the behavior is unchanged (indivId is queued, as before).

One file, +7/−1.

Test plan

  • mvn compile clean
  • Codex adversarial review
  • Manual: assign annotations to a brand-new individual name via IA API; confirm the individual's encounter docs refresh individualNumberEncounters in OpenSearch without waiting for the background reconciler

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@JasonWildMe JasonWildMe added this to the 10.12 milestone Jul 29, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.23%. Comparing base (7d43097) to head (f4e1240).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1704   +/-   ##
=======================================
  Coverage   51.23%   51.23%           
=======================================
  Files         312      312           
  Lines       12396    12396           
  Branches     3993     3993           
=======================================
  Hits         6351     6351           
  Misses       5763     5763           
  Partials      282      282           
Flag Coverage Δ
backend 51.23% <ø> (ø)
frontend 51.23% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JasonWildMe JasonWildMe self-assigned this Jul 30, 2026
@JasonWildMe
JasonWildMe requested a review from naknomum July 30, 2026 04:04

@naknomum naknomum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants