MarketSquare / MarketSquare/robotframework-requests

Better error message when expecting JSON but get 204 (No content) response

Open
#371 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accepted bug
Dominant language
Python
Stars
512
Forks
283
PR merge metrics
No merged PRs in 30d

Description

If we do a GET request that expects a JSON response, like so:

```robot
${response}= RequestsLibrary.GET ${url}
```

then if the server returns 204 (no content) instead of returning JSON, we get this error:
```
Replacing variables from keyword return value failed: Resolving variable '${response.json()}' failed: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```

I think it'd be nice to have a friendly error message for this. Perhaps something like `Expected the response to contain JSON, but the response was 204 (No Content)` 🙂

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the RequestsLibrary.GET keyword and the response.json() handling described in the report, then reproduce the case with a GET request returning HTTP 204. Done means that an empty 204 response produces a friendly, specific error instead of the raw JSONDecodeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.