[go: up one dir, main page]

HTTP error 400 when using get_ossr_records

Bug description and behavior

I received http400 error when using the get_ossr_records with all_versions to False or True

Steps to reproduce

python -c "from eossr.api.ossr import get_ossr_records; r = get_ossr_records(all_versions=False);"

If I authenticated correctly, it fixes the problem but not when using all_versions=True.

Expected behavior?

get_ossr_records should retrieve the ossr records list correctly.

Relevant logs and/or screenshots

File "<truncated_path>/.venv/lib/python3.11/site-packages/eossr/api/zenodo/zenodo.py", line 1098, in query_records
    return _query('records', search=search, sandbox=sandbox, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<truncated_path>/.venv/lib/python3.11/site-packages/eossr/api/zenodo/zenodo.py", line 1360, in _query
    http_status.ZenodoHTTPStatus(response)
  File "<truncated_path>/.venv/lib/python3.11/site-packages/eossr/api/zenodo/http_status.py", line 84, in __init__
    self.raise_error()
  File "<truncated_path>.venv/lib/python3.11/site-packages/eossr/api/zenodo/http_status.py", line 117, in raise_error
    raise HTTPStatusError(msg)
eossr.api.zenodo.http_status.HTTPStatusError: HTTP Status Code: 400 - Bad Request.
Request failed. Error response included.
{'status': 400, 'message': 'A validation error occurred.', 'errors': [{'field': 'size', 'messages': ['Page size cannot be greater than 25. Please use authenticated requests to increase the limit to 100.']}]}

Possible fixes

(If you can, link to the line of code that might be responsible for the problem) Zenodo API has changes and now limits requests to 25 when no authentication and 100 when authenticated. The get_ossr_records returns 54 when all_versions=False, and 251 when all_versions=True.

eossr/api/zenodo/zenodo.py should use pagination to retrrieve the records safely.

(Please add other relevant labels if any)