Skip to content

fix double json (de)serialisation

Yannick requested to merge bug/chunking_json_422 into master

There was a double json deserialisation in chunking feature when dealing with json format. In ddms_v3_utils.py/DMSV3RouterUtils.get_df_from_request in case on json format, it did that:

content = await request.json()
...
return DataframeSerializer.read_json(content, orient)

both line did a json deserialisation. Fix done by directly getting raw body from the request await request.body() instead of await request.json()

Unfortunately there was also a double serialisation in the tests as well hidding this bug. Tests are doing stuff like that:

client.post(url, json=chunk_dataframe.to_json(orient='split'))

chunk_dataframe.to_json performs a first json serialisation. But passing data using 'json' keyword in the post method performs also a json serialisation. Fix by using 'data' instead:

client.post(url, data=chunk_dataframe.to_json(orient='split'))
Edited by Yannick

Merge request reports