cthoyt / zenodo-client

A tool for automated uploading and version management of scientific data to Zenodo
MIT License
25 stars 5 forks source link

Error for creators without orcid #3

Closed mberr closed 1 year ago

mberr commented 2 years ago

When trying to create a record with at least one creator not having an ORCID, an HTTPError is raised

Traceback (most recent call last):
  File "upload.py", line 90, in main
    res = ensure_zenodo(
  File ".../venv/lib/python3.8/site-packages/zenodo_client/api.py", line 44, in ensure_zenodo
    res = create_zenodo(data, paths, **kwargs)
  File ".../venv/lib/python3.8/site-packages/zenodo_client/api.py", line 53, in create_zenodo
    return Zenodo(**kwargs).create(data, paths)
  File ".../venv/lib/python3.8/site-packages/zenodo_client/api.py", line 123, in create
    res.raise_for_status()
  File ".../venv/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: BAD REQUEST for url: https://sandbox.zenodo.org/api/deposit/depositions?access_token=...

By inspecting the .json of the failed POST request, additional information is revealed

{"errors": [{"field": "metadata.creators.3.orcid",
             "message": "Field may not be null."}],
 "message": "Validation error.",
 "status": 400}

From the description of creators in https://developers.zenodo.org/#representation, it seems as if optional entries which assume their null value should not be present, rather than having null in them. On top level, this is already filtered correctly https://github.com/cthoyt/zenodo-client/blob/893a601d2901113a84270a6b1b591790884c70ac/src/zenodo_client/api.py#L102-L105

but the null entries occur on a nested level inside one of the creators.