From 74177bb78b7ece89e9c0d905d6deca8f5e0f9ab4 Mon Sep 17 00:00:00 2001 From: Anandashankar Anil Date: Tue, 7 Oct 2025 16:43:04 +0200 Subject: [PATCH] Cloudant raises exception if document is not found --- scripts/escalation_running_notes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/escalation_running_notes.py b/scripts/escalation_running_notes.py index 3a92974..fafd261 100644 --- a/scripts/escalation_running_notes.py +++ b/scripts/escalation_running_notes.py @@ -14,6 +14,7 @@ import markdown import yaml from genologics_sql.utils import get_session +from ibm_cloud_sdk_core.api_exception import ApiException from sqlalchemy import text from sqlalchemy.orm import aliased @@ -74,7 +75,10 @@ def make_esc_running_note( def update_note_db(note): updated = False - note_existing = couch.get_document(db=db, doc_id=note["_id"]).get_result() + try: + note_existing = couch.get_document(db=db, doc_id=note["_id"]).get_result() + except ApiException: + note_existing = None if "_rev" in note.keys(): del note["_rev"]