The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Discord channel for questions: https://discord.gg/TwKeFahmPZ
When there's a single item in an array or dictionary, masonite converts it into normal form like string or number. Take a look at the following example of a POST request.
For eg:
{
"name": "Family",
"contacts": [ "User One" ]
}
The above request gives an invalid record in the controller. Take a look at the response:
# controller
def my_controller(self, request: Request):
data = request.all()
The above data has the following data in it, which is wrong because the user is expecting an array there.
{
"name": "Family",
"contacts": "User One"
}
Expected behaviour
The correct response should be something like the below:
{
"name": "Family",
"contacts": [
"User One"
]
}
Steps to reproduce the bug
Post the following data in your post route:
{
"name": "Family",
"contacts": ["User One"]
}
Check the response, you'll get the wrong response, which should look like this:
{
"name": "Family",
"contacts": "User One"
}
But the response should be like this:
{
"name": "Family",
"contacts": ["User One"]
}
Screenshots
No response
OS
macOS
OS version
Ventura 13.2.1
Browser
No response
Masonite Version
4.17.4
Anything else ?
Yes, the above issue persists in all data types. I mean if there's an array of dictionaries and has only one item in it then: it will return one dictionary only instead of an array of a dictionary.
Describe the bug
When there's a single item in an array or dictionary, masonite converts it into normal form like
string
ornumber
. Take a look at the following example of aPOST
request.For eg:
The above request gives an invalid record in the controller. Take a look at the response:
The above data has the following data in it, which is wrong because the user is expecting an array there.
Expected behaviour
The correct response should be something like the below:
Steps to reproduce the bug
Screenshots
No response
OS
macOS
OS version
Ventura 13.2.1
Browser
No response
Masonite Version
4.17.4
Anything else ?
Yes, the above issue persists in all data types. I mean if there's an array of dictionaries and has only one item in it then: it will return one dictionary only instead of an array of a dictionary.
Request example:
Current Response
Expected Response