Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(mcp-host): treat dashboard status words named like Object properties as unknown

marcoteb178afa074ccd
diff --git a/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts b/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts
index 73deb4423..e82ccffaa 100644
--- a/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts
+++ b/mcp-host/src/workflow/__tests__/internalTools.dashboard.fidelity.test.ts
@@ -253,6 +253,21 @@ describe('service status and incident severity', () => {
expect(notes).not.toContain('data.services[3]')
})
+ it('treats words that name Object properties as unknown', async () => {
+ const { html, notes } = await render({
+ template: 'operations-pulse',
+ data: {
+ title: 'T',
+ services: [{ name: 'A', status: 'constructor' }],
+ incidents: [{ time: '10:00', title: 'a', severity: '__proto__' }],
+ },
+ })
+ expect(html).toContain('data-status="unknown"')
+ expect(html).not.toMatch(/native code|\[object Object\]/)
+ expect(notes).toContain('data.services[0].status "constructor" is not healthy')
+ expect(notes).toContain('data.incidents[0].severity "__proto__" is not critical')
+ })
+
it('shows the severity the caller wrote and colors the known ones', async () => {
const { html, notes } = await render({
template: 'operations-pulse',
diff --git a/mcp-host/src/workflow/internalTools.ts b/mcp-host/src/workflow/internalTools.ts
index d5ddf070e..8dd927d3a 100644
--- a/mcp-host/src/workflow/internalTools.ts
+++ b/mcp-host/src/workflow/internalTools.ts
@@ -4452,6 +4452,12 @@ function renderSectionHtml(s: unknown, where: string): string {
const SERVICE_STATUSES = ['healthy', 'degraded', 'down', 'maintenance'] as const
/** Status words models use, by the card color they mean. */
+/** The entry `words` has for `text`, ignoring case; never one inherited from Object. */
+function ownWord<T>(words: Partial<Record<string, T>>, text: string): T | undefined {
+ const key = text.toLowerCase()
+ return Object.hasOwn(words, key) ? words[key] : undefined
+}
+
const SERVICE_STATUS_WORDS: Partial<Record<string, (typeof SERVICE_STATUSES)[number]>> = {
healthy: 'healthy',
ok: 'healthy',
@@ -4488,7 +4494,7 @@ function renderServiceHealthGrid(
const name = dashText(s.name)
if (!name) throw new Error(`${at}.name is missing; pass the service name.`)
const statusText = dashText(s.status).trim() || 'unknown'
- const status = SERVICE_STATUS_WORDS[statusText.toLowerCase()] ?? 'unknown'
+ const status = ownWord(SERVICE_STATUS_WORDS, statusText) ?? 'unknown'
if (status === 'unknown' && statusText.toLowerCase() !== 'unknown') {
ctx.warnings.push(
`${at}.status ${JSON.stringify(statusText)} is not healthy, degraded, down or ` +
@@ -4555,8 +4561,8 @@ function renderIncidentsTimeline(
)
}
const given = dashText(it.severity).trim()
- const sev = SEVERITY_WORDS[given.toLowerCase()] ?? 'info'
- if (given && !SEVERITY_WORDS[given.toLowerCase()]) {
+ const sev = ownWord(SEVERITY_WORDS, given) ?? 'info'
+ if (given && !ownWord(SEVERITY_WORDS, given)) {
ctx.warnings.push(
`${at}.severity ${JSON.stringify(given)} is not critical, high, medium, low or info, ` +
'so it is shown in the info color.'