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

jstree/children endpoint returns 500 for V1 (legacy) API #645

Open
Pooya-Oladazimi opened this issue Apr 15, 2024 · 6 comments
Open

jstree/children endpoint returns 500 for V1 (legacy) API #645

Pooya-Oladazimi opened this issue Apr 15, 2024 · 6 comments
Labels
bug low priority Workaround available

Comments

@Pooya-Oladazimi
Copy link

Describe the bug
The call to fetch the children for a term in the term tree returns 500.

To Reproduce
Examples:

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FPCO_0000031/jstree/children/3

https://www.ebi.ac.uk/ols4/api/ontologies/ngbo/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000001/jstree/children/0

https://www.ebi.ac.uk/ols4/api/ontologies/agro/properties/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FRO_0000053/jstree/children/3

Expected behavior
Legacy API calls should work.

Screenshots
N/A

Upload minimal complete example
N/A

Additional context
N/A

@jamesamcl
Copy link
Member

jamesamcl commented Apr 15, 2024

The IDs used to be simple numbers in OLS3 but in OLS4 they are base64 strings. See:

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FPCO_0000031/jstree

[ {
  "id" : "aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx",
  "parent" : "#",
  "iri" : "http://purl.obolibrary.org/obo/PCO_0000031",
  "text" : "organismal entity",
  "state" : {
    "opened" : false,
    "selected" : true
  },
  "children" : true,
  "a_attr" : {
    "iri" : "http://purl.obolibrary.org/obo/PCO_0000031",
    "ontology_name" : "agro",
    "title" : "http://purl.obolibrary.org/obo/PCO_0000031",
    "class" : "is_a"
  },
  "ontology_name" : "agro"
}, {
  "id" : "aHR0cDovL3d3dy53My5vcmcvMjAwMi8wNy9vd2wjVGhpbmc=",
  "parent" : "#",
  "iri" : "http://www.w3.org/2002/07/owl#Thing",
  "text" : "Thing",
  "state" : {
    "opened" : true
  },
  "children" : false,
  "a_attr" : {
    "iri" : "http://www.w3.org/2002/07/owl#Thing",
    "ontology_name" : "agro",
    "title" : "http://www.w3.org/2002/07/owl#Thing",
    "class" : "is_a"
  },
  "ontology_name" : "agro"
} ]

Note the ID is aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx. So the correct URL for the children is:

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FPCO_0000031/jstree/children/aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx

which returns

[ {
  "id" : "aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMxO2h0dHA6Ly9wdXJsLm9ib2xpYnJhcnkub3JnL29iby9QQ09fMDAwMDAwMA==",
  "parent" : "aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL1BDT18wMDAwMDMx",
  "iri" : "http://purl.obolibrary.org/obo/PCO_0000000",
  "text" : "collection of organisms",
  "state" : {
    "opened" : false
  },
  "children" : true,
  "a_attr" : {
    "iri" : "http://purl.obolibrary.org/obo/PCO_0000000",
    "ontology_name" : "agro",
    "title" : "http://purl.obolibrary.org/obo/PCO_0000000",
    "class" : "is_a"
  },
  "ontology_name" : "agro"
} ]

This should be compatible with the unmodified tree widget code from OLS3 as we tested it at the time.

The numeric IDs were changed to be base64'd IRIs to ensure the same API call returns the same result every time (as the numbers were not order guaranteed).

@Pooya-Oladazimi
Copy link
Author

@jamesamcl
Many thanks for the clarification.
But it would be nice to return an empty result set when a wrong id is given rather than raise a 500 server issue response code.

@henrietteharmse henrietteharmse added the low priority Workaround available label Apr 16, 2024
@haideriqbal
Copy link
Collaborator

Thanks @jamesamcl for the clarification... in terms of response @Pooya-Oladazimi I believe returning a 404 error instead of an empty set would be a better approach here as the child being searched doesn't exist.

@Pooya-Oladazimi
Copy link
Author

@jamesamcl @haideriqbal

I had a further look at this and noticed a problem with it.

As an example, look at this call that returns the jsTree for the term "generically dependent continuant" from AGRO ontology:
(frontend view: https://www.ebi.ac.uk/ols4/ontologies/agro/classes/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000031)

https://www.ebi.ac.uk/ols4/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000031/jstree?viewMode=All&siblings=false

Now if you decode the base64 "parent" field:
aHR0cDovL3B1cmwub2JvbGlicmFyeS5vcmcvb2JvL0JGT18wMDAwMDAxO2h0dHA6Ly9wdXJsLm9ib2xpYnJhcnkub3JnL29iby9CRk9fMDAwMDAwMg==

you get two Iris:
http://purl.obolibrary.org/obo/BFO_0000001;http://purl.obolibrary.org/obo/BFO_0000002

This is not correct since the term has only one parent and this one is a list of ancestors. Without a direct parent, tree building faces some issues.

The equivalent call in OLS3:
https://service.tib.eu/ts4tib/api/ontologies/agro/terms/http%253A%252F%252Fpurl.obolibrary.org%252Fobo%252FBFO_0000031/jstree?viewMode=All&siblings=false

@jamesamcl
Copy link
Member

jamesamcl commented Apr 23, 2024

The "parent" field indeed contains a base64 string of a concatenated list of ancestors, because that's the only way to uniquely identify the parent node (as the same class can appear multiple times in the tree if there are different paths to it through its ancestors, so just the immediate parent would not be enough).

You're not actually supposed to decode it, it's just a unique identifier for the parent node. In OLS3 numbers were generated (specifically, node IDs from neo4j), in OLS4 we use this string, but it still serves the same purpose.

This API was built to support the tree view widget: https://github.com/EBISPOT/ols-treeview so maybe looking at that code would be helpful

@Pooya-Oladazimi
Copy link
Author

@jamesamcl

Thanks for the quick response. I was under the impression that that parent field is the parent node iri that I use to build a hierarchical list from this flat list. I get it now. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug low priority Workaround available
Projects
None yet
Development

No branches or pull requests

4 participants