new error system
This commit is contained in:
parent
19e22d14b8
commit
4324df5a8b
2 changed files with 19 additions and 0 deletions
|
|
@ -163,6 +163,14 @@ def get_cognify_router() -> APIRouter:
|
||||||
user_manager=user_manager,
|
user_manager=user_manager,
|
||||||
bearer=None,
|
bearer=None,
|
||||||
)
|
)
|
||||||
|
logger.info(
|
||||||
|
f"WebSocket user authenticated for pipeline {pipeline_run_id}",
|
||||||
|
extra={
|
||||||
|
"user_id": user.id,
|
||||||
|
"user_email": user.email,
|
||||||
|
"pipeline_run_id": str(pipeline_run_id),
|
||||||
|
},
|
||||||
|
)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
logger.error(f"Authentication failed: {str(error)}")
|
logger.error(f"Authentication failed: {str(error)}")
|
||||||
await websocket.close(code=WS_1008_POLICY_VIOLATION, reason="Unauthorized")
|
await websocket.close(code=WS_1008_POLICY_VIOLATION, reason="Unauthorized")
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,11 @@ from cognee.modules.users.methods import get_authenticated_user
|
||||||
from cognee.modules.users.models import User
|
from cognee.modules.users.models import User
|
||||||
from cognee.modules.users.exceptions import PermissionDeniedError
|
from cognee.modules.users.exceptions import PermissionDeniedError
|
||||||
from cognee.modules.data.methods import get_history
|
from cognee.modules.data.methods import get_history
|
||||||
|
from cognee.shared.logging_utils import get_logger
|
||||||
from cognee.exceptions import UnsupportedSearchTypeError, InvalidQueryError, NoDataToProcessError
|
from cognee.exceptions import UnsupportedSearchTypeError, InvalidQueryError, NoDataToProcessError
|
||||||
|
|
||||||
|
logger = get_logger()
|
||||||
|
|
||||||
|
|
||||||
class SearchPayloadDTO(InDTO):
|
class SearchPayloadDTO(InDTO):
|
||||||
search_type: SearchType
|
search_type: SearchType
|
||||||
|
|
@ -86,6 +89,14 @@ def get_search_router() -> APIRouter:
|
||||||
# Check if search type is supported
|
# Check if search type is supported
|
||||||
try:
|
try:
|
||||||
search_type = payload.search_type
|
search_type = payload.search_type
|
||||||
|
logger.info(
|
||||||
|
f"Search type validated: {search_type.value}",
|
||||||
|
extra={
|
||||||
|
"search_type": search_type.value,
|
||||||
|
"user_id": user.id,
|
||||||
|
"query_length": len(payload.query),
|
||||||
|
},
|
||||||
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise UnsupportedSearchTypeError(
|
raise UnsupportedSearchTypeError(
|
||||||
search_type=str(payload.search_type), supported_types=[t.value for t in SearchType]
|
search_type=str(payload.search_type), supported_types=[t.value for t in SearchType]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue