mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-28 12:39:54 +02:00
Better error for missing allowed_users / allowed_groups
This commit is contained in:
parent
bf4b63de19
commit
70d7ca5c73
@ -1,5 +1,6 @@
|
||||
import json
|
||||
from functools import partial
|
||||
from typing import cast
|
||||
from uuid import UUID
|
||||
|
||||
from qdrant_client import QdrantClient
|
||||
@ -68,9 +69,26 @@ def get_qdrant_document_cross_connector_metadata(
|
||||
if len(results) == 0:
|
||||
return None
|
||||
payload = get_payload_from_record(results[0])
|
||||
allowed_users = cast(list[str] | None, payload.get(ALLOWED_USERS))
|
||||
allowed_groups = cast(list[str] | None, payload.get(ALLOWED_GROUPS))
|
||||
if allowed_users is None:
|
||||
allowed_users = []
|
||||
logger.error(
|
||||
"Qdrant Index is corrupted, Document found with no user access lists."
|
||||
f"Assuming no users have access to chunk with ID '{doc_chunk_id}'."
|
||||
)
|
||||
if allowed_groups is None:
|
||||
allowed_groups = []
|
||||
logger.error(
|
||||
"Qdrant Index is corrupted, Document found with no groups access lists."
|
||||
f"Assuming no groups have access to chunk with ID '{doc_chunk_id}'."
|
||||
)
|
||||
|
||||
return CrossConnectorDocumentMetadata(
|
||||
allowed_users=payload[ALLOWED_USERS],
|
||||
allowed_user_groups=payload[ALLOWED_GROUPS],
|
||||
# if either `allowed_users` or `allowed_groups` are missing from the
|
||||
# point, then assume that the document has no allowed users.
|
||||
allowed_users=allowed_users,
|
||||
allowed_user_groups=allowed_groups,
|
||||
already_in_index=True,
|
||||
)
|
||||
|
||||
|
@ -92,13 +92,25 @@ def get_typesense_document_cross_connector_metadata(
|
||||
)
|
||||
except ObjectNotFound:
|
||||
return None
|
||||
if document[ALLOWED_USERS] is None or document[ALLOWED_GROUPS] is None:
|
||||
raise RuntimeError(
|
||||
"Typesense Index is corrupted, Document found with no access lists."
|
||||
|
||||
allowed_users = cast(list[str] | None, document.get(ALLOWED_USERS))
|
||||
allowed_groups = cast(list[str] | None, document.get(ALLOWED_GROUPS))
|
||||
if allowed_users is None:
|
||||
allowed_users = []
|
||||
logger.error(
|
||||
"Typesense Index is corrupted, Document found with no user access lists."
|
||||
f"Assuming no users have access to chunk with ID '{doc_chunk_id}'."
|
||||
)
|
||||
if allowed_groups is None:
|
||||
allowed_groups = []
|
||||
logger.error(
|
||||
"Typesense Index is corrupted, Document found with no groups access lists."
|
||||
f"Assuming no groups have access to chunk with ID '{doc_chunk_id}'."
|
||||
)
|
||||
|
||||
return CrossConnectorDocumentMetadata(
|
||||
allowed_users=document[ALLOWED_USERS],
|
||||
allowed_user_groups=document[ALLOWED_GROUPS],
|
||||
allowed_users=allowed_users,
|
||||
allowed_user_groups=allowed_groups,
|
||||
already_in_index=True,
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user