Skip to content

Fix: templates with no painted domains resolve to null (VFB_00050000)#78

Merged
Robbie1977 merged 1 commit into
mainfrom
fix/template-domains-empty-index
Jul 16, 2026
Merged

Fix: templates with no painted domains resolve to null (VFB_00050000)#78
Robbie1977 merged 1 commit into
mainfrom
fix/template-domains-empty-index

Conversation

@Robbie1977

Copy link
Copy Markdown
Contributor

Problem

get_term_info?id=VFB_00050000 resolves to null (HTTP 200), even though the term is a valid, indexed template — L1 larval CNS ssTEM - Cardona/Janelia ("Seymour"), the L1EM larval template.

The server log blames SOLR:

Finished '.../solr/vfb_json/select/?q=id%3AVFB_00050000&wt=json' ... status 200
No results found for ID 'VFB_00050000'
Error details: list index out of range
Error accessing SOLR server!

…but SOLR is fine. q=id:VFB_00050000 on vfb_json returns numFound=1 with a well-formed term_info. The doc is found; parsing crashes.

Root cause

term_info_parse_object iterates template_domains and runs int(image.index[0]) on every entry unconditionally (vfb_queries.py). Templates with no painted anatomical domains still emit a single empty domain from the pipeline (index: [], null anatomical_individual, empty center). image.index[0] on the empty list raises IndexError: list index out of range.

That exception propagates to get_term_info's broad except IndexError, which mis-reports it as "Error accessing SOLR server!" and returns None → the endpoint serves null for the whole term.

Adult templates (e.g. VFB_00101567 JRC2018Unisex, 47 domains) were unaffected because their domains are all well-formed — which is why only this larval template fails.

Note: the parallel template_channel block just above already guards this exact pattern with if len(image.index) > 0; the guard was simply never copied to the template_domains loop.

Fix

Skip degenerate/empty domains in the template_domains loop, mirroring the existing template_channel guard. One targeted change plus a live regression test.

Verification

  • Before (unpatched HEAD): get_term_info('VFB_00050000')None, reproducing the exact log (list index out of range → "Error accessing SOLR server!").
  • After: resolves with IsTemplate: True, Id: VFB_00050000, the empty domain dropped (Domains: 0), template image retained.
  • No regression: VFB_00101567 still parses with all 47 painted domains.
  • New test src/test/test_template_no_painted_domains.py passes (runs live with VFBQUERY_CACHE_ENABLED=false to force the synchronous parse path).

Follow-up (not in this PR)

The except IndexError in get_term_info masks any parse-time IndexError as a SOLR access error, which is what made this hard to diagnose. Worth narrowing it (or logging a traceback) so future parse bugs surface honestly. Separately, the pipeline could emit template_domains: [] rather than a single empty placeholder domain.

🤖 Generated with Claude Code

get_term_info returned null (HTTP 200) for templates that carry no painted
anatomical domains, e.g. VFB_00050000 (L1EM larval template, 'Seymour').

Such templates still emit a single empty template_domain from the pipeline
(index: [], null anatomical_individual). term_info_parse_object ran
int(image.index[0]) on every domain unconditionally, so the empty index list
raised IndexError: list index out of range. That propagated to get_term_info's
except IndexError handler, which mis-reported it as 'Error accessing SOLR
server!' and returned None -> the endpoint served null for a valid, indexed
template. The doc is present in vfb_json (numFound=1); SOLR was never at fault.

Guard the template_domains loop by skipping degenerate/empty domains, mirroring
the existing 'if len(image.index) > 0' guard already used for template_channel.
Adds a live regression test (VFB_00050000 must resolve, empty domain dropped).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PFzAZQZDiqVDkGkSprSwRw
@Robbie1977
Robbie1977 merged commit 41d2bfb into main Jul 16, 2026
3 of 4 checks passed
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.

1 participant