Skip to content

Commit

Permalink
Handle missing ontology in database_tasks.py
Browse files Browse the repository at this point in the history
Added error handling to safely handle cases where the ontology name is not present in the data. This prevents the function from crashing and adds a failure message to the notifications instead.
  • Loading branch information
Zerskk committed Nov 19, 2024
1 parent ba6d135 commit cfb87d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/tasks/database_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ def update_ontologies(self, task_results):
notifications = notifications.dict()
return notifications

ontology_name = data.get("ontologies")[0].get("name")

try:
ontology_name = data.get("ontologies")[0].get("name")
except:
notifications.messages.append(
Message(type="fail", message="No valid ontology found, skipping..."))
return notifications

# get list of to deleted terms
db_term_list = conn.list_terms_of_ontology(ontology_name)
Expand Down

0 comments on commit cfb87d9

Please sign in to comment.