sparckles / Robyn

Robyn is a Super Fast Async Python Web Framework with a Rust runtime.
https://robyn.tech/
BSD 2-Clause "Simplified" License
3.9k stars 198 forks source link

Incorrect Data Types in JSON Serialization from Python Client to Server #816

Open areqq opened 1 month ago

areqq commented 1 month ago

Bug Description

    d = {'lid': int(lid), 'start': None, 'field_name': 'mobile', 'field_value': number }
    h = {'Content-Type': 'application/json;'}
    r = requests.post('https://xxxxx/api/pimeditor/openField', json = d, headers = h)

I send: {'lid': 570, 'start': None, 'field_name': 'mobile', 'field_value': '111000111'}

@app.post("/api/pimeditor/openField")
async def openField(request):
    j = request.json()
    logger.info(f"{request.headers['x-real-ip']}:{request.query_params.get('app','?')} {request.url.path} {j}")

I got: {'field_name': 'mobile', 'field_value': '111000111', 'lid': '570', 'start': 'null'}

So, the JSON data received on the server has incorrect data types for some fields:

The lid field is sent as an integer (570) but is received as a string ("570"). The start field is sent as None but is received as the string "null".

Steps to Reproduce

No response

Your operating system

Linux

Your Python version (python --version)

3.11

Your Robyn version

latest

Additional Info

No response

sansyrox commented 1 month ago

Hey @areqq 👋

Thanks for raising this. This is a limitation as of now. We are working on fixing this.