fix: include S3 status in /api/health for settings panel

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-08-23 08:31:09 -05:00
parent c4fcc086be
commit e4ab15149e

View File

@ -282,6 +282,26 @@ async def health() -> dict[str, Any]:
except Exception as exc:
return {"ok": False, "error": str(exc)[:120]}
def _s3() -> dict[str, Any]:
from . import s3_storage
enabled = s3_storage.s3_enabled()
info: dict[str, Any] = {
"enabled": enabled,
"ok": False,
"endpoint": settings.s3_endpoint,
"bucket": settings.s3_bucket,
"public_base": settings.s3_public_base,
}
if not enabled:
return info
try:
s3_storage._client().head_bucket(Bucket=settings.s3_bucket) # noqa: SLF001
info["ok"] = True
except Exception as exc:
info["error"] = str(exc)[:120]
return info
try:
pb, yt = await asyncio.wait_for(asyncio.gather(_pb(), _yt()), timeout=1.2)
out["pocketbase"] = pb
@ -289,6 +309,10 @@ async def health() -> dict[str, Any]:
except Exception as exc:
out["pocketbase"] = {"ok": False, "error": "timeout"}
out["youtube"] = {"ok": False, "error": str(exc)[:80]}
try:
out["s3"] = await asyncio.wait_for(asyncio.to_thread(_s3), timeout=1.0)
except Exception as exc:
out["s3"] = {"enabled": False, "ok": False, "error": str(exc)[:120]}
return out