Page MenuHomePhabricator

Fix inconsistencies in JSON object error schema
Closed, ResolvedPublic

Description

MR: https://gitlab.wikimedia.org/repos/generated-data-platform/aqs/unique-devices/-/merge_requests/12

  • Add a bad request validation wrapper to set response status code and error message.
  • add a function for internal server errors
  • Replace problem api with aqsassist createProblem utility function to make all response objects consistent.

Details

Other Assignee
codebug

Event Timeline

@codebug Do you have the input you need for this one?

@JArguello-WMF I do. the first task of this is waiting to be merged, then the second can be completed

Test status: QA PASS

Prod Json error response for Scenario: invalid project

{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/not_found', 'title': 'Not found.', 'method': 'get', 'detail': 'The date(s) you used are valid, but we either do not have data for those date(s), or the project you asked for is not loaded yet.  Please check https://wikimedia.org/api/rest_v1/?doc for more information.', 'uri': '/analytics.wikimedia.org/v1/unique-devices/en.wikipedia.org1/all-sites/daily/20200220/20200225'}

Local Json error response for Scenario: invalid project

{'detail': ['The date(s) you used are valid, but we either do not have data for those date(s), or the project you asked for is not loaded yet.  Please check documentation for more information.'], 'method': 'get', 'status': 404, 'title': 'Not Found', 'type': 'about:blank', 'uri': '/metrics/unique-devices/en.wikipedia.org1/all-sites/daily/20200220/20200225'}

Prod Json error response for Scenario: invalid granularity

{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/bad_request', 'title': 'Invalid parameters', 'method': 'get', 'detail': 'data.params.granularity should be equal to one of the allowed values: [daily, monthly]', 'uri': '/wikimedia.org/v1/metrics/unique-devices/en.wikipedia.org/all-sites/wrongdate/20200220/20200225'}

LocalJson error response for Scenario: invalid granularity

{'detail': ['Invalid granularity'], 'method': 'get', 'status': 400, 'title': 'Bad Request', 'type': 'about:blank', 'uri': '/metrics/unique-devices/en.wikipedia.org/all-sites/wrongdate/20200220/20200225'}

Prod Json error response for Scenario : End date before start date

{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/invalid_request', 'method': 'get', 'detail': ['start timestamp should be before the end timestamp'], 'uri': '/analytics.wikimedia.org/v1/unique-devices/en.wikipedia.org/all-sites/daily/20200229/20200225'}

Local Json error response for Scenario : End date before start date

{'detail': ['start timestamp should be before the end timestamp'], 'method': 'get', 'status': 400, 'title': 'Bad Request', 'type': 'about:blank', 'uri': '/metrics/unique-devices/en.wikipedia.org/all-sites/daily/20200229/20200225'}

Prod Json error response for Scenario : Invalid start date

{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/invalid_request', 'method': 'get', 'detail': ['start timestamp is invalid, must be a valid date in YYYYMMDD format'], 'uri': '/analytics.wikimedia.org/v1/unique-devices/en.wikipedia.org/all-sites/daily/invalid/20200225'}

Local Json error response for Scenario : Invalid start date

{'detail': ['start timestamp is invalid, must be a valid date in YYYYMMDD format'], 'method': 'get', 'status': 400, 'title': 'Bad Request', 'type': 'about:blank', 'uri': '/metrics/unique-devices/en.wikipedia.org/all-sites/daily/invalid/20200225'}

Prod Json error response for Scenario : Invalid End date

{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/invalid_request', 'method': 'get', 'detail': ['end timestamp is invalid, must be a valid date in YYYYMMDD format'], 'uri': '/analytics.wikimedia.org/v1/unique-devices/en.wikipedia.org/all-sites/daily/20200220/invalid'}

Local Json error response for Scenario : Invalid End date

{'detail': ['end timestamp is invalid, must be a valid date in YYYYMMDD format'], 'method': 'get', 'status': 400, 'title': 'Bad Request', 'type': 'about:blank', 'uri': '/metrics/unique-devices/en.wikipedia.org/all-sites/daily/20200229/invalid'}

There is a separate scenario with the invalid route where this is not returning the proper error json but this can be treated in a separate scenario in T329010