Coder Social home page Coder Social logo

Comments (1)

edeutsch avatar edeutsch commented on August 29, 2024 1

At ProteomeCentral and PeptideAtlas, this is the way things look:

First, if you give a bad URL, then our Python flask framework returns an answer like this:

$ curl -i http://proteomecentral.proteomexchange.org/api/proxi/v0.1/xxx

HTTP/1.1 404 NOT FOUND
Date: Thu, 23 Apr 2020 04:20:23 GMT
Server: Werkzeug/0.16.0 Python/3.7.4
Content-Type: application/problem+json
Content-Length: 205
Access-Control-Allow-Origin: *

{
"detail": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"status": 404,
"title": "Not Found",
"type": "about:blank"
}

I modeled the 501 message after this:

$ curl -i http://proteomecentral.proteomexchange.org/api/proxi/v0.1/proteins?resultType=compact

HTTP/1.1 501 NOT IMPLEMENTED
Date: Thu, 23 Apr 2020 04:22:46 GMT
Server: Werkzeug/0.16.0 Python/3.7.4
Content-Type: application/json
Content-Length: 201
Access-Control-Allow-Origin: *
Connection: close

{
"detail": "Although this is an officially defined PROXI endpoint, it has not yet been implemented at this server",
"status": 501,
"title": "Endpoint not implemented",
"type": "about:blank"
}

At PRIDE, the framework returns something that doesn't exist like this:

$ curl -i http://wwwdev.ebi.ac.uk/pride/proxi/archive/v0.1/xxx

HTTP/1.1 404
Content-Type: application/json;charset=UTF-8
Date: Thu, 23 Apr 2020 04:24:00 GMT
Transfer-Encoding: chunked
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Access-Control-Allow-Headers, Authorization
X-Cache-Info: caching

{
"timestamp" : 1587615840686,
"status" : 404,
"error" : "Not Found",
"message" : "No message available",
"path" : "/pride/proxi/archive/v0.1/xxx"
}

and you're returning a 501 like this:

$ curl -i http://wwwdev.ebi.ac.uk/pride/proxi/archive/v0.1/proteins?resultType=compact

HTTP/1.1 501
Content-Type: application/json;charset=UTF-8
Date: Thu, 23 Apr 2020 04:25:31 GMT
Transfer-Encoding: chunked
Access-Control-Allow-Origin: *
Connection: close
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Access-Control-Allow-Headers, Authorization
X-Cache-Info: caching

{
"code" : 501,
"message" : "Not Implemented"
}

At MassIVE we have this:

$ curl -i http://ccms-internal.ucsd.edu/ProteoSAFe/proxi/v0.1/xxx
HTTP/1.1 404 Not Found
Date: Thu, 23 Apr 2020 04:27:27 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 1030
Connection: close

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

HTTP Status 404 - /ProteoSAFe/proxi/v0.1/xxx


type Status report

message /ProteoSAFe/proxi/v0.1/xxx

description The requested resource (/ProteoSAFe/proxi/v0.1/xxx) is not available.


Apache Tomcat/6.0.24

(that's HTML that may not render well in a GutHub issue)

Even specifically asking for JSON doesn't seem to work:

$ curl -i --header "Accept: application/json" http://ccms-internal.ucsd.edu/ProteoSAFe/proxi/v0.1/xxx

HTTP/1.1 404 Not Found
Date: Thu, 23 Apr 2020 04:28:38 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 1030
Connection: close

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

HTTP Status 404 - /ProteoSAFe/proxi/v0.1/xxx


type Status report

message /ProteoSAFe/proxi/v0.1/xxx

description The requested resource (/ProteoSAFe/proxi/v0.1/xxx) is not available.


Apache Tomcat/6.0.24

Seems like JSON should come back..
If asking for a unimplemented endpoint we get:

$ curl -i --header "Accept: application/json" http://ccms-internal.ucsd.edu/ProteoSAFe/proxi/v0.1/proteins?resultType=compact
HTTP/1.1 501 Not Implemented
Date: Thu, 23 Apr 2020 04:33:16 GMT
Set-Cookie: JSESSIONID=F75E68EB1B0AA0A0C601634E80677B6E; Path=/ProteoSAFe
Content-Type: text/html;charset=utf-8
Content-Length: 1292
Connection: close

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

HTTP Status 501 - Although this is an officially defined PROXI endpoint, it has not yet been implemented at this server


type Status report

message Although this is an officially defined PROXI endpoint, it has not yet been implemented at this server

description The server does not support the functionality needed to fulfill this request (Although this is an officially defined PROXI endpoint, it has not yet been implemented at this server).


Apache Tomcat/6.0.24

What's the best way?

I don't know. On the one hand it would be nice if all PROXI servers returned the same style for 400 and 404 and 500 and 501. On the other hand, Consistency among all errors for one server seems perhaps more useful. Too bad the different framework providers cannot even agree on the right way to do it.

I rather like the way things work at ProteomeCentral and PeptideAtlas, the HTTP status has the right number and is also named. And the JSON is simple and consistent and provides a nice English language description of what the problem is. But that's just the Python Flask way of doing it. I'm happy to change error codes that I have control over (400 a no data 404 and a 501), but I don't have control over the framework provided bad URL 404 and 500, etc. Well, that's probably not completely true, there are probably ways to override the default behavior.

Good fodder for discussion.

from proxi-schemas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.