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

Code before:
            if provider == "local":
                os.makedirs(base_config.data_root_directory, exist_ok=True)
                # Simple write/read test
                test_file = os.path.join(base_config.data_root_directory, "health_check_test")
                with open(test_file, "w") as f:
                    f.write("test")
                os.remove(test_file)
            else:
                # For S3, test basic operations
                test_path = "health_check_test"
                await storage.store(test_path, b"test")
                await storage.delete(test_path)

            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.HEALTHY,
                provider=provider,
                response_time_ms=response_time,
                details="Storage accessible",
            )
        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"Storage test failed: {str(e)}",
            )

    async def check_llm_provider(self) -> ComponentHealth:
        """Check LLM provider health (non-critical)."""
        start_time = time.time()
        try:
            from cognee.infrastructure.llm.get_llm_client import get_llm_client
            from cognee.infrastructure.llm.config import get_llm_config

            config = get_llm_config()

            # Test actual API connection with minimal request
            client = get_llm_client()
            await client.acomplete("test", max_tokens=1)

            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.HEALTHY,
                provider=config.llm_provider,
                response_time_ms=response_time,
                details="API responding",
            )
        except Exception as e:
            response_time = int((time.time() - start_time) * 1000)

Review comment (bug):
```suggestion
            response_time = int((time.time() - start_time) * 1000)
            logger.error(f"File storage health check failed: {str(e)}", exc_info=True)
            return ComponentHealth(
```

Code after:
            provider = "s3" if base_config.data_root_directory.startswith("s3://") else "local"

            # Test storage accessibility - for local storage, just check directory exists
            if provider == "local":
                os.makedirs(base_config.data_root_directory, exist_ok=True)
                # Simple write/read test
                test_file = os.path.join(base_config.data_root_directory, "health_check_test")
                with open(test_file, "w") as f:
                    f.write("test")
                os.remove(test_file)
            else:
                # For S3, test basic operations
                test_path = "health_check_test"
                await storage.store(test_path, b"test")
                await storage.delete(test_path)

            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.HEALTHY,
                provider=provider,
                response_time_ms=response_time,
                details="Storage accessible",
            )
        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"Storage test failed: {str(e)}",
            )

    async def check_llm_provider(self) -> ComponentHealth:
        """Check LLM provider health (non-critical)."""
        start_time = time.time()
        try:
            from cognee.infrastructure.llm.get_llm_client import get_llm_client
            from cognee.infrastructure.llm.config import get_llm_config

            config = get_llm_config()

            # Test actual API connection with minimal request
            client = get_llm_client()
            await client.show_prompt("test", "test")

            response_time = int((time.time() - start_time) * 1000)
            return ComponentHealth(
                status=HealthStatus.HEALTHY,
                provider=config.llm_provider,
                response_time_ms=response_time,
                details="API responding",