Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
bug maintenance slack (#1939)
Thibault Le Ouay55f2e5326edc
diff --git a/apps/server/src/routes/slack/agent.ts b/apps/server/src/routes/slack/agent.tsindex d21b207bc..2fcc20bda 100644--- a/apps/server/src/routes/slack/agent.ts+++ b/apps/server/src/routes/slack/agent.ts@@ -18,12 +18,13 @@ function buildSystemPrompt(workspaceName: string): string {return `You are the OpenStatus assistant for workspace "${workspaceName}".You help teams create and manage status reports and maintenance windows through Slack.-IMPORTANT: You have NO knowledge of this workspace's data. NEVER guess or make up status pages, components, or reports. ALWAYS call the appropriate tool first to get real data.-- Questions about pages or components -> call listStatusPages-- Questions about reports -> call listStatusReports-- Questions about maintenances -> call listMaintenances-- Creating a report -> call listStatusPages first, then createStatusReport-- Scheduling maintenance -> call listStatusPages first, then createMaintenance+IMPORTANT: You have NO knowledge of this workspace's data. NEVER guess or make up IDs (page IDs, component IDs, report IDs). You MUST call the appropriate tool first to get real data.+- Questions about pages or components -> call listStatusPages FIRST+- Questions about reports -> call listStatusReports FIRST+- Questions about maintenances -> call listMaintenances FIRST+- Creating a report -> you MUST call listStatusPages first to get the real pageId, then call createStatusReport with that pageId+- Scheduling maintenance -> you MUST call listStatusPages first to get the real pageId, then call createMaintenance with that pageId+- NEVER pass a pageId you did not receive from listStatusPages. Guessing a pageId WILL cause an error.Capabilities:- Create status reports on status pages (createStatusReport)diff --git a/apps/server/src/routes/slack/blocks.ts b/apps/server/src/routes/slack/blocks.tsindex 4891c4f28..db91e8a12 100644--- a/apps/server/src/routes/slack/blocks.ts+++ b/apps/server/src/routes/slack/blocks.ts@@ -187,13 +187,12 @@ export function buildConfirmationBlocks(break;}case "createMaintenance": {- const { title, message, from, to, pageId, pageComponentIds } =- action.params;+ const { title, message, from, to, pageComponentIds } = action.params;blocks.push({type: "section",text: {type: "mrkdwn",- text: `*Schedule Maintenance*\n\n*Title:* ${title}\n*From:* ${formatDate(from)}\n*To:* ${formatDate(to)}\n*Page ID:* ${pageId}${+ text: `*Schedule Maintenance*\n\n*Title:* ${title}\n*From:* ${formatDate(from)}\n*To:* ${formatDate(to)}${pageComponentIds?.length? `\n*Components:* ${pageComponentIds.join(", ")}`: ""diff --git a/apps/server/src/routes/slack/interactions.test.ts b/apps/server/src/routes/slack/interactions.test.tsindex 27861e06a..0c376456e 100644--- a/apps/server/src/routes/slack/interactions.test.ts+++ b/apps/server/src/routes/slack/interactions.test.ts@@ -394,7 +394,7 @@ describe("createMaintenance execution", () => {expect(cancelCall).toBeDefined();});- test("shows error for invalid page id", async () => {+ test("shows error when AI hallucinates page id", async () => {seedMaintenanceAction({ pageId: 99999 });const res = await signAndPost(app, {@@ -485,7 +485,29 @@ describe("createMaintenance execution", () => {});test("does not leak internal error details to user", async () => {- seedMaintenanceAction({ pageId: 99999 });+ const data = {+ id: "maint-001",+ workspaceId: 2,+ limits: {},+ botToken: "xoxb-test",+ channelId: "C1",+ threadTs: "2.1",+ messageTs: "2.2",+ userId: "U_OWNER",+ createdAt: Date.now(),+ action: {+ type: "createMaintenance" as const,+ params: {+ title: "DB Maintenance",+ message: "Upgrade.",+ from: new Date(Date.now() + 86400000).toISOString(),+ to: new Date(Date.now() + 86400000 + 3600000).toISOString(),+ pageId: 99999,+ },+ },+ };+ redisStore.set(`slack:action:${data.id}`, JSON.stringify(data));+ redisStore.set(`slack:thread:${data.threadTs}`, data.id);await signAndPost(app, {type: "block_actions",diff --git a/apps/server/src/routes/slack/interactions.ts b/apps/server/src/routes/slack/interactions.tsindex a4b9531a2..2900f76bc 100644--- a/apps/server/src/routes/slack/interactions.ts+++ b/apps/server/src/routes/slack/interactions.ts@@ -409,11 +409,11 @@ async function executeAction(.get();if (!pageRecord) {- throw new Error(- `Page ${maintenancePageId} not found in this workspace`,- );+ throw new Error("Page not found in this workspace");}+ const resolvedPageId = pageRecord.id;+let componentIds: number[] = [];if (maintenanceComponentIds?.length) {const numericIds = maintenanceComponentIds.map((id) => Number(id));@@ -440,12 +440,9 @@ async function executeAction(}const componentPageId = validComponents[0]?.pageId;- if (- componentPageId !== null &&- componentPageId !== maintenancePageId- ) {+ if (componentPageId !== null && componentPageId !== resolvedPageId) {throw new Error(- `pageId ${maintenancePageId} does not match the page (${componentPageId}) that the selected components belong to`,+ "Selected components do not belong to the target status page",);}@@ -456,7 +453,7 @@ async function executeAction(.insert(maintenance).values({workspaceId,- pageId: maintenancePageId,+ pageId: resolvedPageId,title,message,from: fromDate,@@ -484,7 +481,9 @@ async function executeAction(});}- const maintenancePageUrl = await getPageUrl(maintenancePageId);+ const maintenancePageUrl = newMaintenance.pageId+ ? await getPageUrl(newMaintenance.pageId)+ : null;await slack.chat.update({channel: channelId,diff --git a/apps/server/src/routes/slack/tools/create-maintenance.ts b/apps/server/src/routes/slack/tools/create-maintenance.tsindex 196d61b0f..bbc2091b9 100644--- a/apps/server/src/routes/slack/tools/create-maintenance.ts+++ b/apps/server/src/routes/slack/tools/create-maintenance.ts@@ -4,7 +4,7 @@ import { z } from "zod";export function createCreateMaintenanceTool() {return tool({description:- "Schedule a maintenance window on a status page. Parse natural language dates into ISO 8601 format (e.g. 'next Friday 2-3 PM' -> proper ISO strings). The maintenance will be shown to the user for confirmation before publishing.",+ "Schedule a maintenance window on a status page. IMPORTANT: You MUST call listStatusPages first to get the real pageId — never guess or make up a pageId. Parse natural language dates into ISO 8601 format (e.g. 'next Friday 2-3 PM' -> proper ISO strings). The maintenance will be shown to the user for confirmation before publishing.",inputSchema: z.object({title: z.string().describe("Short title for the maintenance window"),message: z@@ -18,7 +18,11 @@ export function createCreateMaintenanceTool() {to: z.string().describe("End time in ISO 8601 format (e.g. 2025-03-14T15:00:00Z)"),- pageId: z.number().describe("ID of the status page to post on"),+ pageId: z+ .number()+ .describe(+ "ID of the status page — MUST come from listStatusPages, never guess this value",+ ),pageComponentIds: z.array(z.string()).optional()diff --git a/apps/server/src/routes/slack/tools/create-status-report.ts b/apps/server/src/routes/slack/tools/create-status-report.tsindex ab321c8cd..bb277027d 100644--- a/apps/server/src/routes/slack/tools/create-status-report.ts+++ b/apps/server/src/routes/slack/tools/create-status-report.ts@@ -4,7 +4,7 @@ import { z } from "zod";export function createCreateStatusReportTool() {return tool({description:- "Create a new status report. Draft the title and message based on the conversation. The report will be shown to the user for confirmation before publishing.",+ "Create a new status report. IMPORTANT: You MUST call listStatusPages first to get the real pageId — never guess or make up a pageId. Draft the title and message based on the conversation. The report will be shown to the user for confirmation before publishing.",inputSchema: z.object({title: z.string().describe("Short title for the status report"),status: z@@ -15,7 +15,11 @@ export function createCreateStatusReportTool() {.describe("Professional status update message for the public status page",),- pageId: z.number().describe("ID of the status page to post on"),+ pageId: z+ .number()+ .describe(+ "ID of the status page — MUST come from listStatusPages, never guess this value",+ ),pageComponentIds: z.array(z.string()).optional()