OpenTreeOfLife / phylesystem-api

API access to Open Tree of Life treestore
BSD 2-Clause "Simplified" License
10 stars 5 forks source link

Clean up caching logic (don't swallow 4xx responses) #261

Closed jimallman closed 12 months ago

jimallman commented 1 year ago

We were previously discarding the contents of non-200 responses, but we want to be more discriminating. We should return any payload if possible, regardless sub-500 responses, AND cache the response.

NB - This is working now on devtree

jimallman commented 12 months ago

This change is working well for me on dev, try for example:

curl -v https://devapi.opentreeoflife.org/v3/tree_of_life/subtree -d '{"format":"arguson","height_limit":3,"node_id":"ott372706"}'  -vvv

This returns the complete payload, but with a 400 Bad Request status, as desired:

        // lots of JSON payload
        },
        "mrca": "mrcaott47497ott110766"
    },
    "message": "[/v3/tree_of_life/subtree] Error: node_id was not found (broken taxon).\n"
}