Commit 4df666f2 authored by Daniele Venzano's avatar Daniele Venzano

First check for None, then assert correct type

parent c63082f9
......@@ -44,9 +44,9 @@ class APIEndpoint:
def execution_by_id(self, uid, role, execution_id) -> zoe_lib.sql_manager.Execution:
"""Lookup an execution by its ID."""
e = self.sql.execution_list(id=execution_id, only_one=True)
assert isinstance(e, zoe_lib.sql_manager.Execution)
if e is None:
raise zoe_api.exceptions.ZoeNotFoundException('No such execution')
assert isinstance(e, zoe_lib.sql_manager.Execution)
if e.user_id != uid and role != 'admin':
raise zoe_api.exceptions.ZoeAuthException()
return e
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment