Fixed 400 error when author of ticket is no longer an active user in a Zendesk account. (#3168)

This commit is contained in:
James Jordan 2024-11-23 15:15:38 -05:00 committed by GitHub
parent a0065b01af
commit d9b87bbbc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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(