You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 2, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 2, 2020. It is now read-only.
Badge field 'type' is not 'required', but the request fails if it's not supplied #90
I get a 500 error when POSTing a new badge if I don't supply the 'type' field in the request body. The error message is ER_BAD_NULL_ERROR: Column 'type' cannot be null. I assume there's a list of 'required fields' somewhere - if 'type' is required, it should be added to that list; if not, the schema should be changed so that badges.type is allowed to be null.
Funnily enough I came across this one myself earlier.. Not sure if it's meant to be required or not but will need to check on it and various other things I'm not sure about 😉
Hoping to get through all of the endpoints within the next few days so the docs on the master branch should be updated and a lot more detailed then..
Thanks! To clarify, it should be listed both in the documentation, and in the error-checking routines in the code. For instance, if you leave out 'earnerDescription' and 'consumerDescription', the server gives you back a 'ValidationError' code and a 'details' list that tells you which fields were missing.
Thanks for updating the docs! Unfortunately, this is still only half-fixed.
When I try to create a badge that's missing another field, like consumerDescription, I get back an HTTP 400, Bad Request, and a nice JSON error that looks like this:
As an author of a client library, I can format that into an Exception that lists the missing fields, and the user of my client can presumably do something intelligent with this, like show an error message on the relevant form field.
By contrast, when I try to create a badge that's missing the type field, I get an HTTP 500, and this response:
{"message": "ER_BAD_NULL_ERROR: Column 'type' cannot be null"}
This indicates that the missing field is not being caught by the validation layer, but makes it all the way to the database before being noticed. So the JS representation of what fields are required doesn't match the database. I can't make as useful an Exception from this, and the 500 error code means "something went wrong with the server", so it's not as obvious that the request was the problem.
Honestly, this is not a big problem for me, because I don't expect to be making badges in my application. So don't prioritize it on my behalf, but it might still be a good opportunity to make sure the validation routines match the database's expectations.
Thanks for updating the docs! Unfortunately, this is still only half-fixed.
When I try to create a badge that's missing another field, like
consumerDescription, I get back an HTTP 400, Bad Request, and a nice JSON
error that looks like this:
As an author of a client library, I can format that into an Exception that
lists the missing fields, and the user of my client can presumably do
something intelligent with this, like show an error message on the relevant
form field.
By contrast, when I try to create a badge that's missing the type field,
I get an HTTP 500, and this response:
{"message": "ER_BAD_NULL_ERROR: Column 'type' cannot be null"}
This indicates that the missing field is not being caught by the
validation layer, but makes it all the way to the database before being
noticed. So the JS representation of what fields are required doesn't match
the database. I can't make as useful an Exception from this, and the 500
error code means "something went wrong with the server", so it's not as
obvious that the request was the problem.
Honestly, this is not a big problem for me, because I don't expect to be
making badges in my application. So don't prioritize it on my behalf, but
it might still be a good opportunity to make sure the validation routines
match the database's expectations.
—
Reply to this email directly or view it on GitHub #90 (comment).
Activity
SueSmith commentedon May 28, 2014
I'm working through the docs at the moment here https://github.com/mozilla/badgekit-api/tree/doc-updates/docs
Funnily enough I came across this one myself earlier.. Not sure if it's meant to be required or not but will need to check on it and various other things I'm not sure about 😉
Hoping to get through all of the endpoints within the next few days so the docs on the master branch should be updated and a lot more detailed then..
tgs commentedon May 28, 2014
Thanks! To clarify, it should be listed both in the documentation, and in the error-checking routines in the code. For instance, if you leave out 'earnerDescription' and 'consumerDescription', the server gives you back a 'ValidationError' code and a 'details' list that tells you which fields were missing.
SueSmith commentedon May 28, 2014
Ah cool, thanks for clarifying.
Update badges.md
cmcavoy commentedon Jun 6, 2014
Docs updated in #91.
tgs commentedon Jun 9, 2014
Thanks for updating the docs! Unfortunately, this is still only half-fixed.
When I try to create a badge that's missing another field, like
consumerDescription, I get back an HTTP 400, Bad Request, and a nice JSON error that looks like this:As an author of a client library, I can format that into an Exception that lists the missing fields, and the user of my client can presumably do something intelligent with this, like show an error message on the relevant form field.
By contrast, when I try to create a badge that's missing the
typefield, I get an HTTP 500, and this response:This indicates that the missing field is not being caught by the validation layer, but makes it all the way to the database before being noticed. So the JS representation of what fields are required doesn't match the database. I can't make as useful an Exception from this, and the 500 error code means "something went wrong with the server", so it's not as obvious that the request was the problem.
Honestly, this is not a big problem for me, because I don't expect to be making badges in my application. So don't prioritize it on my behalf, but it might still be a good opportunity to make sure the validation routines match the database's expectations.
cmcavoy commentedon Jun 10, 2014
Thanks @tgs this also points out that we need to standardize error
responses.
On Mon, Jun 9, 2014 at 12:01 PM, Thomas Smith notifications@github.com
wrote: