Repository: topoteretes/cognee
File: cognee/api/health.py (Python)

Code before:
        except Exception as e:
            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.UNHEALTHY,
                provider="unknown",
                response_time_ms=response_time,
                details=f"Connection failed: {str(e)}",
            )

    async def check_graph_db(self) -> ComponentHealth:
        """Check graph database health."""
        start_time = time.time()
        try:
            from cognee.infrastructure.databases.graph.get_graph_engine import get_graph_engine
            from cognee.infrastructure.databases.graph.config import get_graph_config

            config = get_graph_config()
            engine = await get_graph_engine()

            # Test basic operation with actual graph query
            if hasattr(engine, "execute"):
                # For SQL-like graph DBs (Neo4j, Memgraph)
                await engine.execute("MATCH () RETURN count(*) LIMIT 1")
            elif hasattr(engine, "get_nodes"):
                # For other graph engines - try to get nodes
                list(engine.get_nodes(limit=1))
            # If engine exists but no test method, consider it healthy

            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.HEALTHY,
                provider=config.graph_database_provider,
                response_time_ms=response_time,
                details="Schema validated",
            )
        except Exception as e:
            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.UNHEALTHY,
                provider="unknown",
                response_time_ms=response_time,
                details=f"Connection failed: {str(e)}",
            )

    async def check_file_storage(self) -> ComponentHealth:
        """Check file storage health."""
        start_time = time.time()
        try:
            import os
            from cognee.infrastructure.files.storage.get_file_storage import get_file_storage
            from cognee.base_config import get_base_config

Review comment (suggestion):
`get_nodes` doesn't support that parameter.

Let's go simpler, we can do `engine.query("MATCH () RETURN count(*) LIMIT 1", {})` which should work

Code after:
            )
        except Exception as e:
            response_time = int((time.time() - start_time) * 1000)
            logger.error(f"Vector DB health check failed: {str(e)}", exc_info=True)
            return ComponentHealth(
                status=HealthStatus.UNHEALTHY,
                provider="unknown",
                response_time_ms=response_time,
                details=f"Connection failed: {str(e)}",
            )

    async def check_graph_db(self) -> ComponentHealth:
        """Check graph database health."""
        start_time = time.time()
        try:
            from cognee.infrastructure.databases.graph.get_graph_engine import get_graph_engine
            from cognee.infrastructure.databases.graph.config import get_graph_config

            config = get_graph_config()
            engine = await get_graph_engine()

            # Test basic operation with actual graph query
            if hasattr(engine, "execute"):
                # For SQL-like graph DBs (Neo4j, Memgraph)
                await engine.execute("MATCH () RETURN count(*) LIMIT 1")
            elif hasattr(engine, "query"):
                # For other graph engines
                engine.query("MATCH () RETURN count(*) LIMIT 1", {})
            # If engine exists but no test method, consider it healthy

            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.HEALTHY,
                provider=config.graph_database_provider,
                response_time_ms=response_time,
                details="Schema validated",
            )
        except Exception as e:
            response_time = int((time.time() - start_time) * 1000)
            logger.error(f"Graph DB health check failed: {str(e)}", exc_info=True)
            return ComponentHealth(
                status=HealthStatus.UNHEALTHY,
                provider="unknown",
                response_time_ms=response_time,
                details=f"Connection failed: {str(e)}",
            )

    async def check_file_storage(self) -> ComponentHealth:
        """Check file storage health."""
        start_time = time.time()
        try: