euroargodev / euroargodev/argopy

CI tests failing with "Test_ArgoDocs::test_search[docid=None-where=abstract] - KeyError: 'AB'"

Open
#393 1 comment 0 reactions 0 assignees View on GitHub
bug CI stale
Dominant language
Python
Stars
229
Forks
52
Avg merge
2d 10h
Merged PRs (30d)
8

Description

Some CI tests, **apparently quite randomly**, fail with a:
```
FAILED argopy/tests/test_related.py::Test_ArgoDocs::test_search[docid=None-where=abstract] - KeyError: 'AB'
```

eg with:
https://github.com/euroargodev/argopy/actions/runs/10940750386/job/30373858695#step:11:1683

gives the error trace:
```
=================================== FAILURES ===================================
_____________ Test_ArgoDocs.test_search[docid=None-where=abstract] _____________

self =
where = 'abstract'
an_instance =
- 26 documents with a DOI are available in the catalogue
> Use the method 'search' to find a document id
> Use the property 'list' to check out the catalogue content

@pytest.mark.parametrize("where", ['title', 'abstract'], indirect=False,
ids=["where=%s" % t for t in ['title', 'abstract']])
@pytest.mark.parametrize("an_instance", [None], indirect=True, ids=["docid=%s" % t for t in [None]])
def test_search(self, where, an_instance):
txt = "CDOM"
> results = an_instance.search(txt, where=where)

argopy/tests/test_related.py:261:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
argopy/related/argo_documentation.py:232: in search
if txt.lower() in ArgoDocs(docid).abstract.lower():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[KeyError('UR') raised in repr()] ArgoDocs object at 0x7fd2d77c7d90>

@property
def abstract(self):
"""Abstract of a document"""
if self.docid is not None:
> return self.ris['AB']
E KeyError: 'AB'

argopy/related/argo_documentation.py:163: KeyError
```

that is very weird because this test is supposedly using a mocked http server, hence correct and always available data !

Most of the time, re-launching the failed test will make it pass on the 2nd attempt

Contributor guide

Open the contributing guide

Research direction

Start by running argopy/tests/test_related.py::Test_ArgoDocs::test_search and inspect the traceback in argopy/related/argo_documentation.py, especially the abstract property and search method. Check why the mocked catalogue data sometimes lacks the AB RIS field, then confirm the test passes reliably across repeated CI runs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.