Skip to content

Commit

Permalink
Fixed 400 error when author of ticket is no longer an active user in …
Browse files Browse the repository at this point in the history
…a Zendesk account. (danswer-ai#3168)
  • Loading branch information
jwjordan authored and ahmadassaf committed Nov 25, 2024
1 parent 44c213f commit bbba5cb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions backend/danswer/connectors/zendesk/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit bbba5cb

Please sign in to comment.