Skip to content

Client throws exception when successful response returns a 204 #5

@ABizzinotto

Description

@ABizzinotto

Description

When making a PUT or DELETE request, or really any request that returns an HTTP status 204, the request succeeds but the client throws an exception:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/amandabizzinotto/ombubots/venv/lib/python3.11/site-packages/freckle_client/client.py", line 134, in fetch_json
    return json.loads(content)
           ^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/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)

Expected Result

If the request succeeds, no exceptions should be thrown. If there is no content in the response to return, it should return None to explicitly indicate there was no content but the request was successful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions