Skip to content

Commit

Permalink
Handle empty stmt_rows
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaris committed Dec 20, 2024
1 parent 3f99a79 commit 7dcdc98
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/indra_cogex/apps/data_display/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,12 @@ def get_evidence(stmt_hash):
# <Statement> expects this json structure:
# resp_json.statements[hash].evidence
# Note that 'stmt_hash' and 'source_hash' need to be strings
return jsonify(
{"statements": {str(stmt_hash): {"evidence": json.loads(stmt_rows[0][0])}}}
)
if stmt_rows:
return jsonify(
{"statements": {str(stmt_hash): {"evidence": json.loads(stmt_rows[0][0])}}}
)
else:
return jsonify({"statements": {str(stmt_hash): {"evidence": []}}})
except Exception as err:
logger.exception(err)
abort(HTTPStatus.INTERNAL_SERVER_ERROR, "Error fetching evidence")
Expand Down

0 comments on commit 7dcdc98

Please sign in to comment.