ncbo / bioportal-project

Serves to consolidate (in Zenhub) all public issues in BioPortal
BSD 2-Clause "Simplified" License
8 stars 5 forks source link

ontology class view is erroring out in the UI for SKOS ontologies #318

Closed alexskr closed 4 months ago

alexskr commented 4 months ago

The HRAVS (skos) ontology class view is erroring in production and staging UI. I don't see any errors on the API side.

I, [2024-07-17T09:11:40.918975 #154484]  INFO -- : Started GET "/ajax/classes/treeview?ontology=HRAVS&conceptid=root" for 68.65.175.39 at 2024-07-17 09:11:40 -0700
I, [2024-07-17T09:11:40.920560 #154484]  INFO -- : Processing by ConceptsController#show_tree as */*
I, [2024-07-17T09:11:40.920794 #154484]  INFO -- :   Parameters: {"ontology"=>"HRAVS", "conceptid"=>"root"}
I, [2024-07-17T09:11:41.258860 #154484]  INFO -- : Completed 500 Internal Server Error in 338ms (ActiveRecord: 0.0ms | Allocations: 266971)
F, [2024-07-17T09:11:41.260758 #154484] FATAL -- :
NoMethodError (undefined method `self' for nil:NilClass):

app/controllers/application_controller.rb:397:in `get_class'
app/controllers/concepts_controller.rb:56:in `show_tree'
I, [2024-07-17T09:11:41.261566 #154484]  INFO -- : Processing by ErrorsController#internal_server_error as */*
I, [2024-07-17T09:11:41.261714 #154484]  INFO -- :   Parameters: {"ontology"=>"HRAVS", "conceptid"=>"root"}
(Duration: 0.7ms | Allocations: 234)
...
I, [2024-07-17T09:11:41.272126 #154484]  INFO -- :   Rendered layout layouts/ontology.html.erb (Duration: 6.6ms | Allocations: 3934)
I, [2024-07-17T09:11:41.272469 #154484]  INFO -- : Completed 500 Internal Server Error in 11ms (Views: 7.6ms | ActiveRecord: 0.0ms | Allocations: 6169)
I, [2024-07-17T09:11:41.276739 #154484]  INFO -- : Started GET "/ontologies/HRAVS?p=notes&ajax=true" for 68.65.xxx.xxx at 2024-07-17 09:11:41 -0700
I, [2024-07-17T09:11:41.277819 #154484]  INFO -- : Processing by OntologiesController#show as HTML

UI has this error when accessing a specific class in the HVARS ontology:

I, [2024-07-17T09:25:26.392985 #154484]  INFO -- : Started GET "/ontologies/HRAVS?p=classes&conceptid=https%3A%2F%2Fpurl.humanatlas.io%2Fvocab%2Fhravs%23HRAVS_1001271" for xxx at 2024-07-17 09:25:26 -0700
I, [2024-07-17T09:25:26.394604 #154484]  INFO -- : Processing by OntologiesController#show as HTML
I, [2024-07-17T09:25:26.394861 #154484]  INFO -- :   Parameters: {"p"=>"classes", "conceptid"=>"https://purl.humanatlas.io/vocab/hravs#HRAVS_1001271", "id"=>"HRAVS"}
D, [2024-07-17T09:25:26.663020 #154484] DEBUG -- :   Ontology Load (1.4ms)  SELECT `ontologies`.* FROM `ontologies` WHERE `ontologies`.`acronym` = 'HRAVS' LIMIT 1
I, [2024-07-17T09:25:26.697687 #154484]  INFO -- : Completed 500 Internal Server Error in 303ms (ActiveRecord: 1.4ms | Allocations: 280269)
F, [2024-07-17T09:25:26.699661 #154484] FATAL -- :
NoMethodError (undefined method `tree' for nil:NilClass):

app/controllers/application_controller.rb:412:in `get_class'
app/controllers/ontologies_controller.rb:135:in `classes'
app/controllers/ontologies_controller.rb:292:in `show'
I, [2024-07-17T09:25:26.700527 #154484]  INFO -- : Processing by ErrorsController#internal_server_error as HTML
I, [2024-07-17T09:25:26.701104 #154484]  INFO -- :   Parameters: {"p"=>"classes", "conceptid"=>"https://purl.humanatlas.io/vocab/hravs#HRAVS_1001271", "id"=>"HRAVS"}
Allocations: 1092)
...
I, [2024-07-17T09:25:26.712172 #154484]  INFO -- :   Rendered layout layouts/ontology.html.erb (Duration: 7.8ms | Allocations: 3846)
I, [2024-07-17T09:25:26.712604 #154484]  INFO -- : Completed 500 Internal Server Error in 11ms (Views: 8.7ms | ActiveRecord: 0.0ms | Allocations: 6003)
I, [2024-07-17T09:25:26.932840 #154484]  INFO -- : Started GET "/ajax/classes/treeview?ontology=undefined&conceptid=undefined" for 10.130.156.22 at 2024-07-17 09:25:26 -0700
I, [2024-07-17T09:25:26.934120 #154484]  INFO -- : Processing by ConceptsController#show_tree as */*
I, [2024-07-17T09:25:26.934350 #154484]  INFO -- :   Parameters: {"ontology"=>"undefined", "conceptid"=>"undefined"}
D, [2024-07-17T09:25:27.230384 #154484] DEBUG -- :   Rendering text template
I, [2024-07-17T09:25:27.230903 #154484]  INFO -- :   Rendered text template (Duration: 0.1ms | Allocations: 16)
I, [2024-07-17T09:25:27.231376 #154484]  INFO -- : Completed 200 OK in 297ms (Views: 1.5ms | ActiveRecord: 0.0ms | Allocations: 253637)
alexskr commented 4 months ago

This issue manifested itself with the API release v5.30.0 and seem to affect all SKOS ontologies

mdorf commented 4 months ago

I narrowed down the cause of this issue. Before the multilingual changes, when a class was serialized, it was assigned the following type:

@type="http://www.w3.org/2002/07/owl#Class

After the multilingual changes the type of a class for SKOS ontologies ONLY has changed to:

@type="http://www.w3.org/2004/02/skos/core#Concept

As a result, the serializer is incorrectly converting the object, resulting in a general OpenStruct instead of the object of type LinkedData::Client::Models::Class

Example of Non-SKOS ontology (correctly serialized):

[12] pry(#<OntologiesController>)> roots
=> [#<LinkedData::Client::Models::Class:0x00000001233abca8
  @context=
   {"@vocab"=>"http://data.bioontology.org/metadata/",
    "prefLabel"=>"http://www.w3.org/2004/02/skos/core#prefLabel",
    "synonym"=>"http://www.w3.org/2004/02/skos/core#altLabel",

Example of a SKOS ontology (incorrectly serialized):

[6] pry(#<OntologiesController>)> roots
=> [#<OpenStruct links={"self"=>"http://localhost:9393/ontologies/HRAVS/classes/https%3A%2F%2Fpurl.humanatlas.io%2Fvocab%2Fhravs%23HRAVS_3000090", "ontology"=>"http://localhost:9393/ontologies/HRAVS", "children"=>"http://localhost:9393/ontologi

The code in question is located here: https://github.com/ncbo/ontologies_linked_data/blob/master/lib/ontologies_linked_data/serializers/json.rb#L83

syphax-bouazzouni commented 4 months ago

Hello this PR https://github.com/ncbo/ontologies_api_ruby_client/pull/17 fixes that