aws / aws/chalice

Dict with `NaN` values been serialised to malformed JSON

Open
#926 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
11.1k
Forks
1k
Avg merge
1d 22h
Merged PRs (30d)
2

Description

Using Python 3.6

Below is the most basic example of the issue

**app.py**

```
@app.route('/mytest', methods=['GET'])
def mytest():
data = {
"number": float('NaN')
}
return data
```

This will return in this **invalid** JSON

```
{
"number": NaN
}
```

This is the same JSON which is generated by

```
data = {
"number": float('NaN')
}
json.dumps(data)
```

Contributor guide

Open the contributing guide

Research direction

Start with the app.py reproduction and compare the endpoint response with Python's json.dumps(data) behavior for float('NaN'). Trace the response serialization entry point and its tests; done means the reported NaN case no longer produces malformed JSON, with the expected handling captured in a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
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.