teresantns / DesafioConstrudelas

Final project for the Construdelas academy, in which I built a loyalty program API
1 stars 0 forks source link

Blank checkbox on referral on PUT method gives MultiValueDictKeyError #10

Closed teresantns closed 2 years ago

teresantns commented 2 years ago

Related to #4

In the endpoint designed for accepting a referral, currently trying to update the referral with an empty checkbox on 'status' field (i.e. rejecting the referral) gives a MultiValueDictKeyError.

image Example of put method which returns the error

Requests with the checkbox checked (meaning a true value on boolean field, ergo accepting the referral) don't return any error, and everything works as it should with the point system.

This may be related with this issue some people had with empty boolean fields.

teresantns commented 2 years ago

This issue doesn't seem to happen with the JSON raw data method of request

image Example of PUT method with raw JSON data, which doesn't return the error

Updating the referral instance this way doesn't return any errors, and everything works as expected.

teresantns commented 2 years ago

After some research, I found that this behaviour is due to the way boolean fields work in HTML, as mentioned by the comments on a discussion revolving the same issue.

Since the API endpoint works as expected with the request in JSON form, this is not a bug that damages the behaviour of the referral acceptance. Nevertheless, it is probably something that would likely have to be addressed by the front end team, or be noticed while building a enhanced page for this endpoint