Skip to content

Commit

Permalink
Fix issue with Confluence errors not being ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
Weves committed Aug 21, 2023
1 parent 9f1898c commit b16a8bb
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions backend/danswer/connectors/confluence/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime
from datetime import timezone
from typing import Any
from typing import cast
from urllib.parse import urlparse

from atlassian import Confluence # type:ignore
Expand Down Expand Up @@ -125,25 +126,27 @@ def _fetch(start_ind: int, batch_size: int) -> Collection[dict[str, Any]]:

return pages

def _fetch_comments(
self, confluence_client: Confluence, page_id: str
) -> Collection[dict[str, Any]]:
def _fetch_comments(self, confluence_client: Confluence, page_id: str) -> str:
try:
return confluence_client.get_page_child_by_type(
page_id,
type="comment",
start=None,
limit=None,
expand="body.storage.value",
comment_pages = cast(
Collection[dict[str, Any]],
confluence_client.get_page_child_by_type(
page_id,
type="comment",
start=None,
limit=None,
expand="body.storage.value",
),
)
return _comment_dfs("", comment_pages, confluence_client)
except Exception as e:
if not self.continue_on_failure:
raise e

logger.exception(
"Ran into exception when fetching comments from Confluence"
)
return []
return ""

def _get_doc_batch(
self, start_ind: int, time_filter: Callable[[datetime], bool] | None = None
Expand All @@ -163,8 +166,7 @@ def _get_doc_batch(
page_text = (
page.get("title", "") + "\n" + parse_html_page_basic(page_html)
)
comment_pages = self._fetch_comments(self.confluence_client, page["id"])
comments_text = _comment_dfs("", comment_pages, self.confluence_client)
comments_text = self._fetch_comments(self.confluence_client, page["id"])
page_text += comments_text

page_url = self.wiki_base + page["_links"]["webui"]
Expand Down

0 comments on commit b16a8bb

Please sign in to comment.