diff --git a/backend/danswer/db/engine.py b/backend/danswer/db/engine.py index 5d4753e136a..892448c2007 100644 --- a/backend/danswer/db/engine.py +++ b/backend/danswer/db/engine.py @@ -23,6 +23,7 @@ from sqlalchemy.orm import Session from sqlalchemy.orm import sessionmaker +from danswer.auth.users import BasicAuthenticationError from danswer.configs.app_configs import LOG_POSTGRES_CONN_COUNTS from danswer.configs.app_configs import LOG_POSTGRES_LATENCY from danswer.configs.app_configs import POSTGRES_API_SERVER_POOL_OVERFLOW @@ -426,7 +427,9 @@ def get_session() -> Generator[Session, None, None]: """Generate a database session with the appropriate tenant schema set.""" tenant_id = CURRENT_TENANT_ID_CONTEXTVAR.get() if tenant_id == POSTGRES_DEFAULT_SCHEMA and MULTI_TENANT: - raise HTTPException(status_code=401, detail="User must authenticate") + raise BasicAuthenticationError( + detail="User must authenticate", + ) engine = get_sqlalchemy_engine() diff --git a/backend/danswer/main.py b/backend/danswer/main.py index a9094399702..571c884b3b0 100644 --- a/backend/danswer/main.py +++ b/backend/danswer/main.py @@ -206,7 +206,7 @@ def log_http_error(_: Request, exc: Exception) -> JSONResponse: if isinstance(exc, BasicAuthenticationError): # For BasicAuthenticationError, just log a brief message without stack trace (almost always spam) - logger.error(f"Authentication failed: {str(exc)}") + logger.warning(f"Authentication failed: {str(exc)}") elif status_code >= 400: error_msg = f"{str(exc)}\n" diff --git a/web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx b/web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx index 2e66b5b63e2..4995d9da933 100644 --- a/web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx +++ b/web/src/app/admin/embeddings/pages/EmbeddingFormPage.tsx @@ -3,7 +3,7 @@ import { usePopup } from "@/components/admin/connectors/Popup"; import { HealthCheckBanner } from "@/components/health/healthcheck"; import { EmbeddingModelSelection } from "../EmbeddingModelSelectionForm"; -import { useEffect, useMemo, useState } from "react"; +import { useCallback, useEffect, useMemo, useState } from "react"; import Text from "@/components/ui/text"; import { Button } from "@/components/ui/button"; import { ArrowLeft, ArrowRight, WarningCircle } from "@phosphor-icons/react"; @@ -158,6 +158,26 @@ export default function EmbeddingForm() { searchSettings?.multipass_indexing != advancedEmbeddingDetails.multipass_indexing; + const updateSearch = useCallback(async () => { + if (!selectedProvider) { + return false; + } + const searchSettings = combineSearchSettings( + selectedProvider, + advancedEmbeddingDetails, + rerankingDetails, + selectedProvider.provider_type?.toLowerCase() as EmbeddingProvider | null + ); + + const response = await updateSearchSettings(searchSettings); + if (response.ok) { + return true; + } else { + setPopup({ message: "Failed to update search settings", type: "error" }); + return false; + } + }, [selectedProvider, advancedEmbeddingDetails, rerankingDetails, setPopup]); + const ReIndexingButton = useMemo(() => { const ReIndexingButtonComponent = ({ needsReIndex, @@ -206,7 +226,7 @@ export default function EmbeddingForm() { }; ReIndexingButtonComponent.displayName = "ReIndexingButton"; return ReIndexingButtonComponent; - }, [needsReIndex]); + }, [needsReIndex, updateSearch]); if (!selectedProvider) { return ; @@ -222,23 +242,6 @@ export default function EmbeddingForm() { })); }; - const updateSearch = async () => { - const searchSettings = combineSearchSettings( - selectedProvider, - advancedEmbeddingDetails, - rerankingDetails, - selectedProvider.provider_type?.toLowerCase() as EmbeddingProvider | null - ); - - const response = await updateSearchSettings(searchSettings); - if (response.ok) { - return true; - } else { - setPopup({ message: "Failed to update search settings", type: "error" }); - return false; - } - }; - const navigateToEmbeddingPage = (changedResource: string) => { router.push("/admin/configuration/search?message=search-settings"); };