diff --git a/backend/danswer/background/indexing/run_indexing.py b/backend/danswer/background/indexing/run_indexing.py index a5db15524..1dcd8494f 100644 --- a/backend/danswer/background/indexing/run_indexing.py +++ b/backend/danswer/background/indexing/run_indexing.py @@ -181,7 +181,7 @@ def _run_indexing( ) try: - all_connector_doc_ids = set() + all_connector_doc_ids: set[str] = set() for doc_batch in doc_batch_generator: # Check if connector is disabled mid run and stop if so unless it's the secondary # index being built. We want to populate it even for paused connectors @@ -238,8 +238,8 @@ def _run_indexing( d.id for d in get_documents_for_connector_credential_pair( db_session=db_session, - connector_id=index_attempt.connector_id, - credential_id=index_attempt.credential_id, + connector_id=db_connector.id, + credential_id=db_credential.id, ) } doc_ids_to_remove = list( @@ -252,8 +252,8 @@ def _run_indexing( # delete docs from cc-pair and receive the number of completely deleted docs in return _delete_connector_credential_pair_batch( document_ids=doc_ids_to_remove, - connector_id=index_attempt.connector_id, - credential_id=index_attempt.credential_id, + connector_id=db_connector.id, + credential_id=db_credential.id, document_index=document_index, ) diff --git a/backend/danswer/main.py b/backend/danswer/main.py index f1faa12d8..11337fe30 100644 --- a/backend/danswer/main.py +++ b/backend/danswer/main.py @@ -82,16 +82,24 @@ from danswer.utils.variable_functionality import fetch_versioned_implementation logger = setup_logger() -def validation_exception_handler( - request: Request, exc: RequestValidationError -) -> JSONResponse: +def validation_exception_handler(request: Request, exc: Exception) -> JSONResponse: + if not isinstance(exc, RequestValidationError): + logger.error( + f"Unexpected exception type in validation_exception_handler - {type(exc)}" + ) + raise exc + exc_str = f"{exc}".replace("\n", " ").replace(" ", " ") logger.exception(f"{request}: {exc_str}") content = {"status_code": 422, "message": exc_str, "data": None} return JSONResponse(content=content, status_code=422) -def value_error_handler(_: Request, exc: ValueError) -> JSONResponse: +def value_error_handler(_: Request, exc: Exception) -> JSONResponse: + if not isinstance(exc, ValueError): + logger.error(f"Unexpected exception type in value_error_handler - {type(exc)}") + raise exc + try: raise (exc) except Exception: