fix: catch microdao fetch error in get_node_by_id

This commit is contained in:
Apple
2025-11-30 14:30:04 -08:00
parent 4e90b5153b
commit 941f12cc0e

View File

@@ -2255,15 +2255,21 @@ async def get_node_by_id(node_id: str) -> Optional[dict]:
data = dict(row)
# Fetch MicroDAOs where orchestrator is on this node
microdaos = await pool.fetch("""
SELECT m.id, m.slug, m.name, COUNT(cr.id) as rooms_count
FROM microdaos m
JOIN agents a ON m.orchestrator_agent_id = a.id
LEFT JOIN city_rooms cr ON cr.microdao_id::text = m.id
WHERE a.node_id = $1
GROUP BY m.id, m.slug, m.name
ORDER BY m.name
""", node_id)
try:
microdaos = await pool.fetch("""
SELECT m.id, m.slug, m.name, COUNT(cr.id) as rooms_count
FROM microdaos m
JOIN agents a ON m.orchestrator_agent_id = a.id
LEFT JOIN city_rooms cr ON cr.microdao_id::text = m.id
WHERE a.node_id = $1
GROUP BY m.id, m.slug, m.name
ORDER BY m.name
""", node_id)
except Exception as e:
import logging
logging.getLogger(__name__).error(f"DEBUG Error fetching microdaos: {e}")
# If this fails, just return empty list to avoid breaking the whole page
microdaos = []
data["microdaos"] = [dict(m) for m in microdaos]