bio-ontology-research-group / AberOWL

Ontology repository that provides Reasoning as as Service
http://aber-owl.net
9 stars 3 forks source link

Make API return values more informative #39

Open dosumis opened 8 years ago

dosumis commented 8 years ago

Please could API queries with errors return appropriate http codes / error messages. Some examples:

This returns 200 + results, as it should: http://aber-owl.net/service/api/runQuery.groovy?type=subeq&query=%3Chttp%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_0000050%3E%20SOME%20%3Chttp%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FGO_0006915%3E&ontology=GO

This returns 200 + results - but what are they, given the nonsense query type spec? http://aber-owl.net/service/api/runQuery.groovy?type=asdfufoe&query=%3Chttp%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBFO_0000050%3E%20SOME%20%3Chttp%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FGO_0006915%3E&ontology=GO

Should return 400 + an error indicating unsupported query type.

This returns 200 + empty results: http://aber-owl.net/service/api/runQuery.groovy?type=subeq&query=asfdgerb&ontology=GO {"result":[],"time":1}

I think 200 is OK, but the JSON should include the OWL-API error message in an error field. it is important to be able to distinguish between a valid query with empty results and an invalid query. For an invalid query, it is important to be able to diagnose the problem (the OWL-API error message is good for that).

This returns an incomprehensible error message: http://aber-owl.net/service/api/runQuery.groovy?type=subeq&query=asfdgerb&ontology=asfh java.lang.IllegalArgumentException: URI is not absolute

I think 200 would be OK, but it should return an error indicating that the ontology is unknown

CC @robbie1977

dosumis commented 8 years ago

Hiya,

wondering if you have any plans to address this.

Cheers, David

leechuck commented 8 years ago

Yes, sorry, this is my fault. I have not updated the server with the latest commits from @reality but am doing so now. It should be online tomorrow.

reality commented 8 years ago

Actually this part has not yet been done - Will implement by the end of the day

reality commented 8 years ago

These have now been implemented:

All with 400 response code, and response in a JSON block e.g.

{
    "err": true,
    "message": "Query parsing error: Encountered fdsja at line 1 column 1. Expected one of:\n\tClass name\n\tObject property name\n\tData property name\n\tnot\n\tinverse\n\t(\n\t{\n"
}

The query type defaults to subeq, noted in the documentation - this is also the case if the query type given is nonsensical

reality commented 8 years ago

Going to keep this open because similar methods need to be implemented for other API functions

dosumis commented 8 years ago

Not seeing the new behaviour. Try the links in my original post. They still give the same results

leechuck commented 8 years ago

There should be some additional checks. In case of an error, API returns proper information now. Query types should have strict checking, not fall back to subeq type.

Querying for classes that don't exist in the ontology will return empty results; that's not an error, I would think.

dosumis commented 8 years ago

Querying for classes that don't exist in the ontology will return empty results; that's not an error, I would think.

Knowing what part of a query fails can be very useful in debugging. It's also important to distinguish query fail from cases where no classes or individuals satisfy a query. The OWL API & Protege return errors like this:

  Encountered fu at line 1 column 1. Expected one of:
  Class name
   Object property name
   Data property name
   inverse
   not
   (
   {

It would be very useful if the AberOWL API could do something similar. This looks like the intention of @reality 's description of behaviour above, but perhaps not implemented yet.

http://aber-owl.net/service/api/runQuery.groovy?type=subeq&query=asfdgerb&ontology=GO

Should =>

    {
       "err": true,
        "message": "Query parsing error: Encountered fdsja at line 1 column 1. Expected one of:\n\tClass name\n\tObject property name\n\tData property name\n\tnot\n\tinverse\n\t(\n\t{\n"
     }

But currently => empty result set ( {"result":[],"time":1} )

leechuck commented 8 years ago

Quite true, we will fix that. @reality this needs some thought on how to deal with querying multiple ontologies at once.