Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framework error responses #53

Open
edeutsch opened this issue Feb 13, 2020 · 2 comments
Open

Framework error responses #53

edeutsch opened this issue Feb 13, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request need-discussion

Comments

@edeutsch
Copy link
Contributor

edeutsch commented Feb 13, 2020

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

<title>Apache Tomcat/6.0.24 - Error report</title><style></style>

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":"[email protected]","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
Copy link
Contributor Author

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 ypriverol added the enhancement New feature or request label Feb 13, 2020
@ypriverol
Copy link
Contributor

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need-discussion
Projects
None yet
Development

No branches or pull requests

3 participants