maproulette-backend
maproulette-backend copied to clipboard
Challenge creation/update - default difficulty level not set for invalid values
If the user supplies an invalid integer value for the difficulty level at challenge creation or update the default value is not set for this field. Request JSON:
{
"name": "Misnamed Double Digitized Ways",
"parent": 2,
"identifier": "misnameddoubledigitizedways",
"difficulty": 5,
"description": "",
"blurb": "Double digitized ways with inconsistent naming",
"instruction": "Fix the inconsistent naming of what seems to be a single double-digitized road.",
"help": ""
}
Response JSON:
{"id":31,"name":"Misnamed Double Digitized Ways","description":"","parent":2,"instruction":"Fix the inconsistent naming of what seems to be a single double-digitized road.","difficulty":5,"blurb":"Double digitized ways with inconsistent naming","enabled":true,"challengeType":1,"featured":false}
If the user supplies a non-numeric invalid value for the difficulty level at challenge creation or update the operation fails. In this case the default value should be set.
Request JSON:
{
"name": "Misnamed Double Digitized Ways",
"parent": 2,
"identifier": "misnameddoubledigitizedways",
"difficulty": "blabla",
"description": "",
"blurb": "Double digitized ways with inconsistent naming",
"instruction": "Fix the inconsistent naming of what seems to be a single double-digitized road.",
"help": ""
}
Response JSON:
{"status":"KO","message":{"obj.difficulty":[{"msg":["error.expected.jsnumber"],"args":[],responseCode:400}],responseCode:400},responseCode:400}
Don't agree with the second case, if a string is supplied for a numeric field it should fail. Perhaps the message could be clearer.
For the first case, that's a bug. If difficulty is out of range the request should fail.