python-nomad icon indicating copy to clipboard operation
python-nomad copied to clipboard

[corner case] JSONDecodeError when requesting a `job.summary()` for an empty job ID

Open juditnovak opened this issue 3 months ago • 0 comments

First of all, thank you VERY much for the python-nomad library. I find it very useful working on an Open Source Airflow Nomad Provider

This is a complete corner case, I'm just reporting it for the record.

In case the job ID is an empty string for the job.summary() call, the following exception is raised:

.venv/lib/python3.13/site-packages/nomad/api/job.py:179: in get_summary
    return self.request(id_, "summary", method="get").json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[..]

E           requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

.venv/lib/python3.13/site-packages/requests/models.py:980: JSONDecodeError

I'm wondering that it may be nicer to return a descendant of BaseNomadException, or an empty return value (None/{})

(Also, if you like, I'm glad to offer the PR.)

juditnovak avatar Sep 21 '25 15:09 juditnovak