HUPO-PSI / proxi-schemas

ProXI: Schema definitions for the Proteomics eXpression Interface
3 stars 3 forks source link

Framework error responses #53

Open edeutsch opened 4 years ago

edeutsch commented 4 years ago

Our schema nominally defines an error result as this:

     Error:
         required:
            - code
            - message
          properties:
               code:
                    type: integer
                    format: int32
               message:
                    type: string

We can code that up. But what happens when our frameworks encounter an error like for a schema violation?

ProteomeCentral: curl -i -X GET --header 'Accept: application/json' 'http://proteomecentral.proteomexchange.org/api/proxi/v0.1/datasets?pageSize=100&pageNumber=1&resultType=foo'

HTTP/1.1 400 BAD REQUEST
{
  "detail": "'foo' is not one of ['compact', 'full']\n\nFailed validating 'enum' in schema:\n    {'default': 'compact',\n     'description': 'Type of the object to be retrieve Compact or Full '\n                    'dataset',\n     'enum': ['compact', 'full'],\n     'in': 'query',\n     'name': 'resultType',\n     'type': 'string'}\n\nOn instance:\n    'foo'",
  "status": 400,
  "title": "Bad Request",
  "type": "about:blank"
}

After investigating the framework code, they are implementing this RFC: https://tools.ietf.org/html/draft-ietf-appsawg-http-problem-00

PRIDE: curl -i -X GET --header 'Accept: application/json' 'http://wwwdev.ebi.ac.uk/pride/proxi/archive/v0.1/datasets?pageSize=100&pageNumber=1&resultType=foo'

HTTP/1.1 400 { "timestamp" : 1581580688155, "status" : 400, "error" : "Bad Request", "message" : "Failed to convert value of type 'java.lang.String' to required type 'uk.ac.ebi.pride.ws.pride.utils.WsContastants$ResultType'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.web.bind.annotation.RequestParam uk.ac.ebi.pride.ws.pride.utils.WsContastants$ResultType] for value 'foo'; nested exception is java.lang.IllegalArgumentException: No enum constant uk.ac.ebi.pride.ws.pride.utils.WsContastants.ResultType.foo", "path" : "/pride/proxi/archive/v0.1/datasets" }

MassIVE: curl -i -X GET --header 'Accept: application/json' 'ccms-internal.ucsd.edu/ProteoSAFe/proxi/v0.1/datasets?pageSize=100&pageNumber=1&resultType=foo'

HTTP/1.1 400 Bad Request

Apache Tomcat/6.0.24 - Error report

HTTP Status 400 - Unrecognized "resultType" parameter value [foo]


type Status report

message Unrecognized "resultType" parameter value [foo]

description The request sent by the client was syntactically incorrect (Unrecognized "resultType" parameter value [foo]).


Apache Tomcat/6.0.24

jPOST seems not to mind the schema violation: curl -i -X GET --header 'Accept: application/json' 'https://repository.jpostdb.org/proxi/datasets?resultType=foo&accession=PXD005159'

HTTP/1.1 200 OK [{"accession":[{"name":"jPOST dataset identifier","value":"JPST000200","accession":"MS:1002632","cvLabel":"MS"},{"name":"ProteomeXchange accession number","value":"PXD005159","accession":"MS:1001919","cvLabel":"MS"}],"title":"HeLa standard shotgun DDA analysis using a two-meter C18 monolithic silica column","publications":[{"name":"PubMed identifier","accession":"MS:1000879","value":"","cvLabel":"MS"},{"name":"Reference","accession":"MS:1002866","value":"","cvLabel":"MS"}],"contacts":[[{"name":"dataset submitter","accession":"MS:1002037","cvLabel":"MS"},{"name":"contact name","accession":"MS:1000586","value":"Saki Nambu","cvLabel":"MS"},{"name":"contact email","accession":"MS:1000589","value":"mcba.jpost3@gmail.com","cvLabel":"MS"},{"name":"contact affiliation","accession":"MS:1000590","value":"Kyoto university","cvLabel":"MS"}],[{"name":"lab head","accession":"MS:1002332","cvLabel":"MS"},{"name":"contact name","accession":"MS:1000586","value":"N\/A","cvLabel":"MS"},{"name":"contact affiliation","accession":"MS:1000590","value":"N\/A","cvLabel":"MS"}]],"species":[[{"name":"taxonomy: scientific name","value":"Homo sapiens (Human)","accession":"MS:1001469","cvLabel":"MS"},{"name":"taxonomy: NCBI TaxID","value":"9606","accession":"MS:1001467","cvLabel":"MS"}]],"instruments":[[{"name":"Q Exactive","accession":"MS:1001911","cvLabel":"MS"}]]}]

How do we feel about these results?

edeutsch commented 4 years ago

The Google JSON Guide is probably worth looking at, too: https://google.github.io/styleguide/jsoncstyleguide.xml#Reserved_Property_Names_in_the_error_object

This seems compatible with what our YAML has.. Is this our inspiration?

ypriverol commented 4 years ago

@edeutsch I think for this request we should reply to this query http://proteomecentral.proteomexchange.org/api/proxi/v0.1/datasets?pageSize=100&pageNumber=1&resultType=foo

BAD REQUEST Error

We need to review all the implementations to retrieve the proper error. Probably, will be good to have some code to test alp implementations. I will add this as an issue.