jrxFive / python-nomad

Client library Hashicorp Nomad
https://python-nomad.readthedocs.io/en/latest/
MIT License
139 stars 73 forks source link

JSONDecodeError with `get_jobs` method #159

Open EnzoDelahaye opened 10 months ago

EnzoDelahaye commented 10 months ago

Hello, I got an Exception with the Jobs.get_jobs method. Here is the traceback:

Traceback (most recent call last):
  File "/app/.venv/lib/python3.11/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/app/scheduler/scheduler.py", line 162, in get_running_crawls
    fetched_nomad_jobs = n.jobs.get_jobs(namespace="scrapy")
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/nomad/api/jobs.py", line 96, in get_jobs
    return self.request(method="get", params=params).json()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I got many running jobs on Nomad, the method should return all jobs in the scrapy namespace. Look like no any jobs are retrieved and empty string is passed to complexjson.loads(self.text, **kwargs) I'm using python-nomad 2.0.0

nikita-b commented 4 months ago

Actually, it seems to be a bug with Nomad.... Which version of Nomad are you using?