topoteretes--cognee
c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
238 行
8.0 KiB
Python
238 行
8.0 KiB
Python
from fastapi import status
|
|
from cognee.exceptions import (
|
|
CogneeApiError,
|
|
CogneeSystemError,
|
|
CogneeValidationError,
|
|
CogneeConfigurationError,
|
|
)
|
|
|
|
|
|
class DatabaseNotCreatedError(CogneeSystemError):
|
|
"""
|
|
Represents an error indicating that the database has not been created. This error should
|
|
be raised when an attempt is made to access the database before it has been initialized.
|
|
|
|
Inherits from CogneeSystemError. Overrides the constructor to include a default message and
|
|
status code.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "The database has not been created yet. Please call `await setup()` first.",
|
|
name: str = "DatabaseNotCreatedError",
|
|
status_code: int = status.HTTP_422_UNPROCESSABLE_CONTENT,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class UnsupportedProvenanceCapability(CogneeApiError):
|
|
"""Raised when an adapter does not implement graph provenance operations."""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "This backend does not support graph provenance yet.",
|
|
name: str = "UnsupportedProvenanceCapability",
|
|
status_code: int = status.HTTP_501_NOT_IMPLEMENTED,
|
|
):
|
|
super().__init__(message, name, status_code, log=False)
|
|
|
|
|
|
class EntityNotFoundError(CogneeValidationError):
|
|
"""
|
|
Represents an error when a requested entity is not found in the database. This class
|
|
inherits from CogneeValidationError.
|
|
|
|
Public methods:
|
|
|
|
- __init__ : Initializes the EntityNotFoundError with a specific message, name, and
|
|
status code.
|
|
|
|
Instance variables:
|
|
|
|
- message: A string containing the error message.
|
|
- name: A string representing the name of the error type.
|
|
- status_code: An integer indicating the HTTP status code associated with the error.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "The requested entity does not exist.",
|
|
name: str = "EntityNotFoundError",
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
):
|
|
self.message = message
|
|
self.name = name
|
|
self.status_code = status_code
|
|
# super().__init__(message, name, status_code) :TODO: This is not an error anymore with the dynamic exception handling therefore we shouldn't log error
|
|
|
|
|
|
class EntityAlreadyExistsError(CogneeValidationError):
|
|
"""
|
|
Represents an error when an entity creation is attempted but the entity already exists.
|
|
|
|
This class is derived from CogneeValidationError and is used to signal a conflict in operations
|
|
involving resource creation.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "The entity already exists.",
|
|
name: str = "EntityAlreadyExistsError",
|
|
status_code=status.HTTP_409_CONFLICT,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class NodesetFilterNotSupportedError(CogneeConfigurationError):
|
|
"""
|
|
Raise an exception when a nodeset filter is not supported by the current database.
|
|
|
|
This exception inherits from `CogneeConfigurationError` and is designed to provide information
|
|
about the specific issue of unsupported nodeset filters in the context of graph
|
|
databases.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "The nodeset filter is not supported in the current graph database.",
|
|
name: str = "NodeSetFilterNotSupportedError",
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
):
|
|
self.message = message
|
|
self.name = name
|
|
self.status_code = status_code
|
|
|
|
|
|
class EmbeddingException(CogneeConfigurationError):
|
|
"""
|
|
Custom exception for handling embedding-related errors.
|
|
|
|
This exception class is designed to indicate issues specifically related to embeddings
|
|
within the application. It extends the base exception class CogneeConfigurationError allows
|
|
for customization of the error message, name, and status code.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "Embedding Exception.",
|
|
name: str = "EmbeddingException",
|
|
status_code=status.HTTP_422_UNPROCESSABLE_CONTENT,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class MissingQueryParameterError(CogneeValidationError):
|
|
"""
|
|
Raised when neither 'query_text' nor 'query_vector' is provided,
|
|
and at least one is required to perform the operation.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
name: str = "MissingQueryParameterError",
|
|
status_code: int = status.HTTP_400_BAD_REQUEST,
|
|
):
|
|
message = "One of query_text or query_vector must be provided!"
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class MutuallyExclusiveQueryParametersError(CogneeValidationError):
|
|
"""
|
|
Raised when both 'text' and 'embedding' are provided to the search function,
|
|
but only one type of input is allowed at a time.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
name: str = "MutuallyExclusiveQueryParametersError",
|
|
status_code: int = status.HTTP_400_BAD_REQUEST,
|
|
):
|
|
message = "The search function accepts either text or embedding as input, but not both."
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class CacheConnectionError(CogneeConfigurationError):
|
|
"""
|
|
Raised when connection to the cache database (e.g., Redis) fails.
|
|
|
|
This error indicates that the cache service is unavailable or misconfigured.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "Failed to connect to cache database. Please check your cache configuration.",
|
|
name: str = "CacheConnectionError",
|
|
status_code: int = status.HTTP_503_SERVICE_UNAVAILABLE,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class SessionQAEntryValidationError(CogneeValidationError):
|
|
"""
|
|
Raised when SessionQAEntry model validation fails (e.g., during update_qa_entry).
|
|
|
|
This error indicates that the merged QA entry data does not conform to the
|
|
SessionQAEntry schema (missing required fields, invalid feedback_score, etc.).
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "Session QA entry validation failed. Wrong SessionQAEntry is used during session CRUD operations.",
|
|
name: str = "SessionQAEntryValidationError",
|
|
status_code: int = status.HTTP_422_UNPROCESSABLE_CONTENT,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class SessionParameterValidationError(CogneeValidationError):
|
|
"""
|
|
Raised when SessionManager receives invalid parameters (user_id, session_id, qa_id).
|
|
|
|
This error indicates that one or more required session parameters are empty
|
|
or invalid (e.g., empty string, whitespace-only).
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "Invalid session parameter. user_id, session_id, and qa_id must be non-empty strings.",
|
|
name: str = "SessionParameterValidationError",
|
|
status_code: int = status.HTTP_400_BAD_REQUEST,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
class SharedLadybugLockRequiresRedisError(CogneeConfigurationError):
|
|
"""
|
|
Raised when shared Ladybug locking is requested without configuring the Redis backend.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = (
|
|
"Shared Ladybug lock requires Redis cache backend. Configure Redis to enable shared Ladybug locking."
|
|
),
|
|
name: str = "SharedLadybugLockRequiresRedisError",
|
|
status_code: int = status.HTTP_400_BAD_REQUEST,
|
|
):
|
|
super().__init__(message, name, status_code)
|
|
|
|
|
|
SharedKuzuLockRequiresRedisError = SharedLadybugLockRequiresRedisError
|
|
|
|
|
|
class DatabaseCredentialsError(CogneeConfigurationError):
|
|
"""
|
|
Raised when database credentials are incomplete or invalid.
|
|
|
|
This error indicates that required authentication parameters (e.g., username
|
|
or password) are missing or malformed for a database connection.
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
message: str = "Database credentials are incomplete or invalid. Please check your configuration.",
|
|
name: str = "DatabaseCredentialsError",
|
|
status_code: int = status.HTTP_422_UNPROCESSABLE_CONTENT,
|
|
):
|
|
super().__init__(message, name, status_code)
|