Fix: templates with no painted domains resolve to null (VFB_00050000)#78
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
get_term_info?id=VFB_00050000resolves tonull(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:
…but SOLR is fine.
q=id:VFB_00050000onvfb_jsonreturnsnumFound=1with a well-formedterm_info. The doc is found; parsing crashes.Root cause
term_info_parse_objectiteratestemplate_domainsand runsint(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: [], nullanatomical_individual, emptycenter).image.index[0]on the empty list raisesIndexError: list index out of range.That exception propagates to
get_term_info's broadexcept IndexError, which mis-reports it as "Error accessing SOLR server!" and returnsNone→ the endpoint servesnullfor the whole term.Adult templates (e.g.
VFB_00101567JRC2018Unisex, 47 domains) were unaffected because their domains are all well-formed — which is why only this larval template fails.Note: the parallel
template_channelblock just above already guards this exact pattern withif len(image.index) > 0; the guard was simply never copied to thetemplate_domainsloop.Fix
Skip degenerate/empty domains in the
template_domainsloop, mirroring the existingtemplate_channelguard. One targeted change plus a live regression test.Verification
get_term_info('VFB_00050000')→None, reproducing the exact log (list index out of range→ "Error accessing SOLR server!").IsTemplate: True,Id: VFB_00050000, the empty domain dropped (Domains: 0), template image retained.VFB_00101567still parses with all 47 painted domains.src/test/test_template_no_painted_domains.pypasses (runs live withVFBQUERY_CACHE_ENABLED=falseto force the synchronous parse path).Follow-up (not in this PR)
The
except IndexErroringet_term_infomasks any parse-timeIndexErroras 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 emittemplate_domains: []rather than a single empty placeholder domain.🤖 Generated with Claude Code