anonlink-entity-service icon indicating copy to clipboard operation
anonlink-entity-service copied to clipboard

error response not complying with api specification

Open hardbyte opened this issue 4 years ago • 1 comments

The json returned from the run status endpoint (and probably other endpoints) on json validation error isn't conforming to our json schema specification

Example error:

{
'detail': "2.0 is greater than the maximum of 1.0\n\nFailed validating 'maximum' in schema['properties']['current_stage']['properties']['progress']['properties']['relative']:\n {'description': 'Decimal between 0.0 and 1.0 indicating the relative '\n 'progress of this stage.\\n',\n 'format': 'double',\n 'maximum': 1.0,\n 'minimum': 0.0,\n 'type': 'number'}\n\nOn instance['current_stage']['progress']['relative']:\n 2.0",
 'status': 500, 
'title': 'Response body does not conform to specification', 
'type': 'about:blank'}

The spec is:

{
  "type": "http://anonlink.readthedocs.io/en/latest/problems.html#ratelimited",
  "title": "string",
  "status": 503,
  "detail": "Connection to database timed out",
  "instance": "http://example.com"
}

hardbyte avatar Sep 25 '19 04:09 hardbyte

The spec is this:

  Problem:
    type: object
    properties:
      type:
        type: string
        format: uri
        description: |
          An absolute URI that identifies the problem type.  When dereferenced,
          it SHOULD provide human-readable documentation for the problem type
          (e.g., using HTML).
        default: 'about:blank'
        example: 'http://anonlink.readthedocs.io/en/latest/problems.html#ratelimited'
      title:
        type: string
        description: |
          A short, summary of the problem type. Written in english and readable
          for engineers; example: Service Unavailable
      status:
        type: integer
        format: int32
        description: |
          The HTTP status code generated by the origin server for this occurrence
          of the problem.
        minimum: 100
        maximum: 600
        exclusiveMaximum: true
        example: 503
      detail:
        type: string
        description: |
          A human readable explanation specific to this occurrence of the
          problem.
        example: Connection to database timed out
      instance:
        type: string
        format: uri
        description: |
          An absolute URI that identifies the specific occurrence of the problem.
          It may or may not yield further information if dereferenced.

wilko77 avatar Sep 25 '19 06:09 wilko77