maproulette-backend icon indicating copy to clipboard operation
maproulette-backend copied to clipboard

Challenge creation/update - default difficulty level not set for invalid values

Open tBeata-grab opened this issue 9 years ago • 1 comments

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}

tBeata-grab avatar Jun 13 '16 11:06 tBeata-grab

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.

mvexel avatar Nov 08 '16 18:11 mvexel