From bbba5cbaf2f91e62b68c0be8b1cf9576d0169a0d Mon Sep 17 00:00:00 2001 From: James Jordan Date: Sat, 23 Nov 2024 15:15:38 -0500 Subject: [PATCH] Fixed 400 error when author of ticket is no longer an active user in a Zendesk account. (#3168) --- .../danswer/connectors/zendesk/connector.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/backend/danswer/connectors/zendesk/connector.py b/backend/danswer/connectors/zendesk/connector.py index 195fe45af0f..170da788a76 100644 --- a/backend/danswer/connectors/zendesk/connector.py +++ b/backend/danswer/connectors/zendesk/connector.py @@ -102,13 +102,21 @@ def _get_tickets( def _fetch_author(client: ZendeskClient, author_id: str) -> BasicExpertInfo | None: - author_data = client.make_request(f"users/{author_id}", {}) - user = author_data.get("user") - return ( - BasicExpertInfo(display_name=user.get("name"), email=user.get("email")) - if user and user.get("name") and user.get("email") - else None - ) + # Skip fetching if author_id is invalid + if not author_id or author_id == "-1": + return None + + try: + author_data = client.make_request(f"users/{author_id}", {}) + user = author_data.get("user") + return ( + BasicExpertInfo(display_name=user.get("name"), email=user.get("email")) + if user and user.get("name") and user.get("email") + else None + ) + except requests.exceptions.HTTPError: + # Handle any API errors gracefully + return None def _article_to_document(