Page MenuHomePhabricator

🏈️ Replace framework error with 'missing-field' error for missing top-level fields
Closed, ResolvedPublic

Description

The new error should follow this format:

"code": "missing-field",
"message": "Required field missing",
"context": { 
 "path": "{json_pointer_to_parent}",
 "field": "{missing_field}" 
}

Note:

  • Remember to check if the OAS needs updating as well.
  • Check if e2e tests for top-level fields are there (all edit requests minus DELETE) and add where missing.

Event Timeline

Change #1054276 had a related patch set uploaded (by Muhammad Jaziraly; author: Muhammad Jaziraly):

[mediawiki/extensions/Wikibase@master] REST: Replace framework errors for missing top-level fields

https://gerrit.wikimedia.org/r/1054276

Change #1054276 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] REST: Replace framework errors for missing top-level fields

https://gerrit.wikimedia.org/r/1054276

Can anyone give me a pointer on how I can verify this case?

You can test any POST/PUT/PATCH request (a request that requires a body) with an empty object {} in the request body. e.g. in POST new item, sending an empty object in the request body will cause this error to happen to tell us that the item top-level field is missing from the JSON body.