Skip to content

Empty hits list error still happens after 0.9.3 #120

@svenrdz

Description

@svenrdz

From @orlando-code in #119

When no hits are returned by context's search(), perhaps due to a time-out or incorrect search string, context.py's _distribute_hits_impl attempts to index an empty list. This fails with the following error:

...
  File "../python3.14/site-packages/esgpull/context.py", line 268, in _distribute_hits
    offsets = _distribute_hits_impl(hits, offset)
  File "../python3.14/site-packages/esgpull/context.py", line 250, in _distribute_hits_impl
    accs[i] += steps[i]
    ~~~~^^^
IndexError: list index out of range
IndexError: list index out of range

I ran into the above error when running searches with the bridge index node (index_node = "esgf-node.ornl.gov/esgf-1-5-bridge").

It's not a timeout issue (I made the http_timeout values very large; and the error takes the same length of time to appear). Logger gives this readout:

[2025-12-02 13:46:16]  INFO      esgpull
facets=('project:"CMIP6"', 'activity_id:"ScenarioMIP"', 'experiment_id:"ssp126"', 'institution_id:"CNRM-CERFACS"', 'source_id:"CNRM-ESM2-1"', 'variable_id:"ph"')

...

[2025-12-02 13:46:16]  DEBUG     httpcore.connection
connect_tcp.started host='esgf-node.ornl.gov' port=443 local_address=None timeout=100000 socket_options=None

[2025-12-02 13:46:16]  DEBUG     httpcore.connection
connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x79d652379940>

[2025-12-02 13:46:16]  DEBUG     httpcore.connection
start_tls.started ssl_context=<ssl.SSLContext object at 0x79d654b679b0> server_hostname='esgf-node.ornl.gov' timeout=100000

[2025-12-02 13:46:51]  DEBUG     httpcore.connection
start_tls.failed exception=ConnectError(EndOfStream())

[2025-12-02 13:46:51]  DEBUG     esgpull
fetch (1 sub-exception)
NoneType: None
[2025-12-02 13:46:51]  DEBUG     esgpull

NoneType: None
[2025-12-02 13:46:51]  DEBUG     root
Locals:
{'hits': [], 'max_hits': 0, 'i': 0, 'total': 0, 'N': 0, 'accs': [], 'result': [], 'steps': []}

There was a fix for this error in #110 but it obviously did not fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions