Make the Uptime Kuma maintenance import say what it found

The import route returned its errors as {error} while the page reads
{message}, so a wrong API key or an unreachable Uptime Kuma showed as raw
JSON. Every failure now carries a readable message. An empty result now
says how many monitors were read and that only maintenance active right
now can be imported, and a disabled integration is explained instead of
leaving a greyed-out button. Adds route tests against a stand-in Uptime Kuma.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-11 23:26:32 +02:00
1 parent 3daec601fd
commit 5e416b0273
4 files changed
+134 -7

No files matched your search

+6 -5
View File
@@ -90,15 +90,16 @@ maintenanceRouter.post("/import/uptimekuma", requireRole("operator"), asyncHandl
const { integrationId, minutes } = parsed.data;
const loaded = await loadIntegrationConfig(integrationId);
if (!loaded) return res.status(404).json({ error: "not_found" });
if (loaded.integration.type !== "uptimekuma") return res.status(400).json({ error: "wrong_type" });
if (!loaded.integration.enabled) return res.status(400).json({ error: "integration_disabled" });
if (!loaded) return res.status(404).json({ error: "not_found", message: "That Uptime Kuma integration no longer exists." });
if (loaded.integration.type !== "uptimekuma") return res.status(400).json({ error: "wrong_type", message: "That integration isn't an Uptime Kuma one." });
if (!loaded.integration.enabled) return res.status(400).json({ error: "integration_disabled", message: "That integration is disabled. Enable it under Integrations first." });
let monitors;
try {
monitors = await createUptimeKumaAdapter(loaded.config as any).listMonitors();
} catch (err) {
return res.status(502).json({ error: err instanceof Error ? err.message : String(err) });
const message = err instanceof Error ? err.message : String(err);
return res.status(502).json({ error: "uptimekuma_unreachable", message: `Couldn't read Uptime Kuma: ${message}` });
}
const serverRows = await db.select({ id: servers.id, name: servers.name, hostname: servers.hostname, ips: servers.ipAddresses }).from(servers);
@@ -134,7 +135,7 @@ maintenanceRouter.post("/import/uptimekuma", requireRole("operator"), asyncHandl
imported.push({ serverId: m.matchedServer.id, serverName: result.target.name, monitorName: m.name, extended: result.extended });
}
res.json({ imported, unmatched, monitorsInMaintenance: inMaintenance.length });
res.json({ imported, unmatched, monitorsInMaintenance: inMaintenance.length, monitorsChecked: monitors.length });
}));
maintenanceRouter.delete("/:id", requireRole("operator"), asyncHandler(async (req, res) => {