Conf doc sync improvements (#3643)

* Reduce number of requests to Confluence

* undo

* added a way to dynamically adjust the pagination limit

* undo
This commit is contained in:
hagen-danswer
2025-01-09 12:56:56 -08:00
committed by GitHub
parent 97a963b4bf
commit d40fd82803
2 changed files with 36 additions and 11 deletions

View File

@@ -67,6 +67,13 @@ def _get_server_space_permissions(
else: else:
logger.warning(f"Email for user {user_name} not found in Confluence") logger.warning(f"Email for user {user_name} not found in Confluence")
if not user_emails and not group_names:
logger.warning(
"No user emails or group names found in Confluence space permissions"
f"\nSpace key: {space_key}"
f"\nSpace permissions: {space_permissions}"
)
return ExternalAccess( return ExternalAccess(
external_user_emails=user_emails, external_user_emails=user_emails,
external_user_group_ids=group_names, external_user_group_ids=group_names,

View File

@@ -121,6 +121,7 @@ def handle_confluence_rate_limit(confluence_call: F) -> F:
_DEFAULT_PAGINATION_LIMIT = 1000 _DEFAULT_PAGINATION_LIMIT = 1000
_MINIMUM_PAGINATION_LIMIT = 50
class OnyxConfluence(Confluence): class OnyxConfluence(Confluence):
@@ -204,24 +205,41 @@ class OnyxConfluence(Confluence):
# If the problematic expansion is in the url, replace it # If the problematic expansion is in the url, replace it
# with the replacement expansion and try again # with the replacement expansion and try again
# If that fails, raise the error # If that fails, raise the error
if _PROBLEMATIC_EXPANSIONS not in url_suffix: if _PROBLEMATIC_EXPANSIONS in url_suffix:
logger.exception( logger.warning(
f"Replacing {_PROBLEMATIC_EXPANSIONS} with {_REPLACEMENT_EXPANSIONS}"
" and trying again."
)
url_suffix = url_suffix.replace(
_PROBLEMATIC_EXPANSIONS,
_REPLACEMENT_EXPANSIONS,
)
continue
if (
raw_response.status_code == 500
and limit > _MINIMUM_PAGINATION_LIMIT
):
new_limit = limit // 2
logger.warning(
f"Error in confluence call to {url_suffix} \n" f"Error in confluence call to {url_suffix} \n"
f"Raw Response Text: {raw_response.text} \n" f"Raw Response Text: {raw_response.text} \n"
f"Full Response: {raw_response.__dict__} \n" f"Full Response: {raw_response.__dict__} \n"
f"Error: {e} \n" f"Error: {e} \n"
f"Reducing limit from {limit} to {new_limit} and trying again."
) )
raise e url_suffix = url_suffix.replace(
f"limit={limit}", f"limit={new_limit}"
)
limit = new_limit
continue
logger.warning( logger.exception(
f"Replacing {_PROBLEMATIC_EXPANSIONS} with {_REPLACEMENT_EXPANSIONS}" f"Error in confluence call to {url_suffix} \n"
" and trying again." f"Raw Response Text: {raw_response.text} \n"
f"Full Response: {raw_response.__dict__} \n"
f"Error: {e} \n"
) )
url_suffix = url_suffix.replace( raise e
_PROBLEMATIC_EXPANSIONS,
_REPLACEMENT_EXPANSIONS,
)
continue
try: try:
next_response = raw_response.json() next_response = raw_response.json()