diff --git a/autobot-frontend/src/components/collaboration/PresenceIndicator.vue b/autobot-frontend/src/components/collaboration/PresenceIndicator.vue index e03272793c..875e04e7b6 100644 --- a/autobot-frontend/src/components/collaboration/PresenceIndicator.vue +++ b/autobot-frontend/src/components/collaboration/PresenceIndicator.vue @@ -95,14 +95,14 @@ const props = defineProps<{ class="ml-2 text-xs text-red-400 flex items-center gap-1" > - {{ $t('collaboration.presence.offline') }} + {{ $t('collaboration.presenceIndicator.offline') }}
- {{ $t('collaboration.presence.participants', { count: sessionPresence.length }) }} + {{ $t('collaboration.presenceIndicator.participants', { count: sessionPresence.length }) }}
@@ -118,11 +118,11 @@ const props = defineProps<{ {{ myPresence.username }} - {{ $t('collaboration.presence.you') }} + {{ $t('collaboration.presenceIndicator.you') }}
- {{ $t('collaboration.presence.tabLabel', { tab: myPresence.currentTab || $t('collaboration.presence.unknownTab') }) }} + {{ $t('collaboration.presenceIndicator.tabLabel', { tab: myPresence.currentTab || $t('collaboration.presenceIndicator.unknownTab') }) }}
@@ -142,7 +142,7 @@ const props = defineProps<{
- {{ $t('collaboration.presence.tabLabel', { tab: collaborator.currentTab || $t('collaboration.presence.unknownTab') }) }} + {{ $t('collaboration.presenceIndicator.tabLabel', { tab: collaborator.currentTab || $t('collaboration.presenceIndicator.unknownTab') }) }}
@@ -156,7 +156,7 @@ const props = defineProps<{ class="text-center py-4 text-autobot-text-muted" > -
{{ $t('collaboration.presence.noParticipants') }}
+
{{ $t('collaboration.presenceIndicator.noParticipants') }}
diff --git a/autobot-frontend/src/components/collaboration/__tests__/PresenceIndicator.render.test.ts b/autobot-frontend/src/components/collaboration/__tests__/PresenceIndicator.render.test.ts index 20006653ac..d4c2b936ef 100644 --- a/autobot-frontend/src/components/collaboration/__tests__/PresenceIndicator.render.test.ts +++ b/autobot-frontend/src/components/collaboration/__tests__/PresenceIndicator.render.test.ts @@ -12,6 +12,8 @@ import { describe, it, expect, vi } from 'vitest' import { mount } from '@vue/test-utils' import { ref } from 'vue' +import { createI18n } from 'vue-i18n' +import en from '@/i18n/locales/en.json' import type { UserPresence } from '@/composables/useSessionCollaboration' const state = vi.hoisted(() => ({ presence: [] as unknown[], me: null as unknown })) @@ -68,6 +70,21 @@ describe('PresenceIndicator renders who is present (#16754)', () => { it('the expanded view counts everyone present, me included', () => { const wrapper = mountWith([person('u1', 'ada'), person('u2', 'bob')], true) - expect(wrapper.text()).toContain('collaboration.presence.participants{"count":3}') + expect(wrapper.text()).toContain('collaboration.presenceIndicator.participants{"count":3}') + }) + + // #19416: with the real English bundle, the placeholders resolve: the count and each tab show. + it('the expanded view renders the count and every participant\'s tab from the real strings', () => { + const me = person('me', 'Alex Doe') + state.me = me + state.presence = [me, { ...person('u1', 'ada'), currentTab: 'knowledge' } as UserPresence] + const wrapper = mount(PresenceIndicator, { + props: { expanded: true }, + global: { plugins: [createI18n({ legacy: false, globalInjection: true, locale: 'en', messages: { en } })] }, + }) + const text = wrapper.text() + expect(text).toContain('Participants (2)') + expect(text).toContain('chat tab') + expect(text).toContain('knowledge tab') }) }) diff --git a/autobot-frontend/src/i18n/locales/ar.json b/autobot-frontend/src/i18n/locales/ar.json index e97b9ab249..88ae78a29a 100644 --- a/autobot-frontend/src/i18n/locales/ar.json +++ b/autobot-frontend/src/i18n/locales/ar.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "التعاون", "invite": "دعوة", diff --git a/autobot-frontend/src/i18n/locales/de.json b/autobot-frontend/src/i18n/locales/de.json index 94bd23608a..998e597519 100644 --- a/autobot-frontend/src/i18n/locales/de.json +++ b/autobot-frontend/src/i18n/locales/de.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "Zusammenarbeit", "invite": "Einladen", diff --git a/autobot-frontend/src/i18n/locales/en.json b/autobot-frontend/src/i18n/locales/en.json index 875be87858..551146b992 100644 --- a/autobot-frontend/src/i18n/locales/en.json +++ b/autobot-frontend/src/i18n/locales/en.json @@ -6862,16 +6862,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "collaboratorTooltip": "Collaborator", - "noParticipants": "No participants", - "offline": "Offline", - "participants": "Participants", - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "youStatus": "Your status" - }, "panel": { "title": "Collaboration", "invite": "Invite", diff --git a/autobot-frontend/src/i18n/locales/es.json b/autobot-frontend/src/i18n/locales/es.json index 9f384908fc..217071b399 100644 --- a/autobot-frontend/src/i18n/locales/es.json +++ b/autobot-frontend/src/i18n/locales/es.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "Colaboración", "invite": "Invitar", diff --git a/autobot-frontend/src/i18n/locales/fa.json b/autobot-frontend/src/i18n/locales/fa.json index 3780d9d450..c5c4485e2c 100644 --- a/autobot-frontend/src/i18n/locales/fa.json +++ b/autobot-frontend/src/i18n/locales/fa.json @@ -5120,16 +5120,6 @@ "selectUserError": "Please select a user to invite", "sendFailed": "Failed to send invitation" }, - "presence": { - "participants": "Participants", - "you": "You", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status", - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "noParticipants": "No participants" - }, "participants": { "invite": "Invite", "collaborationOffline": "Collaboration offline", diff --git a/autobot-frontend/src/i18n/locales/fr.json b/autobot-frontend/src/i18n/locales/fr.json index f23ec6e3d9..72ba6864c5 100644 --- a/autobot-frontend/src/i18n/locales/fr.json +++ b/autobot-frontend/src/i18n/locales/fr.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "Espace collaboratif", "invite": "Inviter", diff --git a/autobot-frontend/src/i18n/locales/he.json b/autobot-frontend/src/i18n/locales/he.json index a3bc9d636a..461ab9b302 100644 --- a/autobot-frontend/src/i18n/locales/he.json +++ b/autobot-frontend/src/i18n/locales/he.json @@ -5120,16 +5120,6 @@ "selectUserError": "Please select a user to invite", "sendFailed": "Failed to send invitation" }, - "presence": { - "participants": "Participants", - "you": "You", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status", - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "noParticipants": "No participants" - }, "participants": { "invite": "Invite", "collaborationOffline": "Collaboration offline", diff --git a/autobot-frontend/src/i18n/locales/lv.json b/autobot-frontend/src/i18n/locales/lv.json index 03bd97b4f6..84d4e31427 100644 --- a/autobot-frontend/src/i18n/locales/lv.json +++ b/autobot-frontend/src/i18n/locales/lv.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "Sadarbība", "invite": "Uzaicināt", diff --git a/autobot-frontend/src/i18n/locales/pl.json b/autobot-frontend/src/i18n/locales/pl.json index 252f17767c..9c65b45124 100644 --- a/autobot-frontend/src/i18n/locales/pl.json +++ b/autobot-frontend/src/i18n/locales/pl.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "Współpraca", "invite": "Zaproś", diff --git a/autobot-frontend/src/i18n/locales/pt.json b/autobot-frontend/src/i18n/locales/pt.json index 963afc0bdc..8361e3e52a 100644 --- a/autobot-frontend/src/i18n/locales/pt.json +++ b/autobot-frontend/src/i18n/locales/pt.json @@ -6498,16 +6498,6 @@ "roleOwner": "Owner", "roleViewer": "Viewer" }, - "presence": { - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "you": "You", - "noParticipants": "No participants", - "participants": "Participants", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status" - }, "panel": { "title": "Colaboração", "invite": "Convidar", diff --git a/autobot-frontend/src/i18n/locales/ur.json b/autobot-frontend/src/i18n/locales/ur.json index 45550f6c17..1a8d761768 100644 --- a/autobot-frontend/src/i18n/locales/ur.json +++ b/autobot-frontend/src/i18n/locales/ur.json @@ -5120,16 +5120,6 @@ "selectUserError": "Please select a user to invite", "sendFailed": "Failed to send invitation" }, - "presence": { - "participants": "Participants", - "you": "You", - "offline": "Offline", - "collaboratorTooltip": "Collaborator", - "youStatus": "Your status", - "tabLabel": "Active tab", - "unknownTab": "Unknown tab", - "noParticipants": "No participants" - }, "participants": { "invite": "Invite", "collaborationOffline": "Collaboration offline", diff --git a/autobot-slm-frontend/src/components/fleet/LoadBalancingView.vue b/autobot-slm-frontend/src/components/fleet/LoadBalancingView.vue index 27b96e09e8..02e6af2d35 100644 --- a/autobot-slm-frontend/src/components/fleet/LoadBalancingView.vue +++ b/autobot-slm-frontend/src/components/fleet/LoadBalancingView.vue @@ -166,9 +166,13 @@ async function refreshData(): Promise { // Fetch per-worker configs for priority/weight display const nodeMetrics = fleetMetrics.value?.node_metrics ?? [] - await Promise.all( + // One node's failed config read is logged and does not hide the others' (the store rethrows it). + const results = await Promise.allSettled( nodeMetrics.map(m => fleetStore.fetchNpuWorkerConfig(m.node_id)) ) + results.forEach((r, i) => { + if (r.status === 'rejected') logger.warn(`Worker config load failed for ${nodeMetrics[i].node_id}`, r.reason) + }) } catch (e) { const msg = e instanceof Error ? e.message : t('fleet.loadBalancingView.failedToLoadData') error.value = msg diff --git a/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.nodeSwitch.test.ts b/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.nodeSwitch.test.ts index 448b1a455a..7a27b5eb24 100644 --- a/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.nodeSwitch.test.ts +++ b/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.nodeSwitch.test.ts @@ -21,6 +21,8 @@ vi.mock('@/stores/fleet', () => ({ useFleetStore: () => ({ fetchNpuWorkerConfig, fetchNpuNodeMetrics }), })) +vi.mock('@/i18n', () => ({ default: { global: { t: (k: string) => k } } })) + // The panel translates its save notice through useI18n; the tests mount without the plugin. vi.mock('vue-i18n', () => ({ useI18n: () => ({ t: (k: string) => k }) })) @@ -122,4 +124,16 @@ describe('NPUDetailsPanel node switch', () => { expect(wrapper.findAll('input[type="checkbox"]:checked')).toHaveLength(0) expect((wrapper.find('select').element as HTMLSelectElement).value).toBe('retry') }) + + it('shows a per-node error when a load fails, and clears it for the next node (#19068)', async () => { + fetchNpuNodeMetrics.mockRejectedValueOnce(new Error('metrics unreachable')).mockResolvedValue(metrics(5)) + fetchNpuWorkerConfig.mockResolvedValue(config(2)) + const wrapper = mountPanel() + await flushPromises() + expect(wrapper.text()).toContain('metrics unreachable') + + await wrapper.setProps({ node: nodeB as never }) + await flushPromises() + expect(wrapper.text()).not.toContain('metrics unreachable') + }) }) diff --git a/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.vue b/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.vue index 3445e3c0eb..fe0820acdf 100644 --- a/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.vue +++ b/autobot-slm-frontend/src/components/fleet/NPUDetailsPanel.vue @@ -18,6 +18,7 @@ import { useI18n } from 'vue-i18n' import { useFleetStore } from '@/stores/fleet' import type { SLMNode, NPUNodeStatus, NPUWorkerMetrics, NPUWorkerConfig } from '@/types/slm' import { formatFleetDateTime } from '@/composables/useTimezone' +import { errorText } from '@/utils/errorText' const props = defineProps<{ node: SLMNode @@ -173,7 +174,7 @@ watch( const token = ++loadToken resetNodeState() Promise.all([loadLiveMetrics(token), loadWorkerConfig(token)]).catch((e: unknown) => { - if (isCurrent(token)) error.value = e instanceof Error ? e.message : String(e) + if (isCurrent(token)) error.value = errorText(e) }) }, { immediate: true }, diff --git a/autobot-slm-frontend/src/components/fleet/NPUPerformanceMetrics.vue b/autobot-slm-frontend/src/components/fleet/NPUPerformanceMetrics.vue index 5a17c28846..8c37f20673 100644 --- a/autobot-slm-frontend/src/components/fleet/NPUPerformanceMetrics.vue +++ b/autobot-slm-frontend/src/components/fleet/NPUPerformanceMetrics.vue @@ -88,11 +88,10 @@ function isExpanded(nodeId: string): boolean { const { t } = useI18n() -/** One tick; the store reports a failed read as null, so the tick throws for the poller to count. */ +/** One tick; the store rethrows a failed read, so the poller counts it. */ async function loadMetrics(): Promise { try { - const metrics = await fleetStore.fetchNpuFleetMetrics() - if (metrics === null) throw new Error(fleetStore.error ?? 'NPU fleet metrics unavailable') + await fleetStore.fetchNpuFleetMetrics() } finally { isLoading.value = false } diff --git a/autobot-slm-frontend/src/components/fleet/NPUWorkerMonitor.vue b/autobot-slm-frontend/src/components/fleet/NPUWorkerMonitor.vue index 8cc78e1627..9755e29b49 100644 --- a/autobot-slm-frontend/src/components/fleet/NPUWorkerMonitor.vue +++ b/autobot-slm-frontend/src/components/fleet/NPUWorkerMonitor.vue @@ -125,10 +125,9 @@ const formatTimestamp = createDateFormatter({ kind: 'time', emptyText: 'Never' } const { t } = useI18n() -/** The store reports a failed read as null; throw it, so refresh() shows it and the poller counts it. */ +/** The store rethrows a failed read, so refresh() shows it and the poller counts it. */ async function fetchMetrics(): Promise { const fleetMetrics = await fleetStore.fetchNpuFleetMetrics() - if (fleetMetrics === null) throw new Error(fleetStore.error ?? t('fleet.nPUWorkerMonitor.metricsUnavailable')) if (fleetMetrics.node_metrics) { const newMap = new Map() for (const m of fleetMetrics.node_metrics) { diff --git a/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.protoStatus.test.ts b/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.protoStatus.test.ts new file mode 100644 index 0000000000..cfa30aaef5 --- /dev/null +++ b/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.protoStatus.test.ts @@ -0,0 +1,93 @@ +// Copyright 2025-2026 mrveiss +// SPDX-License-Identifier: Apache-2.0 +// AutoBot - AI-Powered Automation Platform +// Author: mrveiss + +/** + * #17497: a service `status` arrives from the fleet API and from a WebSocket message. An + * `in` allow-list admitted `Object.prototype` members (`constructor`, `toString`, `__proto__`), + * so the status tally went NaN. Own-property semantics leave the tally untouched. + */ + +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { mount, flushPromises } from '@vue/test-utils' + +type StatusHandler = (nodeId: string, data: { service_name: string; status: string; success: boolean }) => void + +const h = vi.hoisted(() => ({ handler: null as null | ((...a: never[]) => void), getNodeServices: vi.fn() })) + +vi.mock('@autobot/ui', () => ({ + BaseAlert: { template: '
' }, + PollingPausedAlert: { template: '
' }, + formatBytes: (n: number) => String(n), + formatRelativeTime: () => 'now', + createLogger: () => ({ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }), +})) +vi.mock('@/components/fleet/ServiceLogsModal.vue', () => ({ default: { template: '
' } })) +vi.mock('@/composables/useSlmApi', () => ({ useSlmApi: () => ({ getNodeServices: h.getNodeServices }) })) +vi.mock('@/composables/useSlmWebSocket', () => ({ + useSlmWebSocket: () => ({ + connect: vi.fn(), + subscribe: vi.fn(), + connected: { value: true }, + onServiceStatus: (fn: (...a: never[]) => void) => { h.handler = fn }, + }), +})) +vi.mock('@/composables/useDashboardPoller', () => ({ + throwUnlessLoaded: vi.fn(), + useDashboardPoller: (tick: () => Promise) => ({ start: () => tick(), stop: vi.fn() }), +})) +vi.mock('@/i18n', () => ({ default: { global: { t: (k: string) => k } } })) + +import NodeServicesPanel from './NodeServicesPanel.vue' + +const svc = (name: string, status: string) => ({ service_name: name, status, node_id: 'n1' }) + +async function mountPanel(services: unknown[]) { + h.getNodeServices.mockResolvedValue({ services, total: services.length }) + const wrapper = mount(NodeServicesPanel, { + props: { nodeId: 'n1' }, + global: { mocks: { $t: (k: string) => k }, stubs: { teleport: true } }, + }) + await flushPromises() + return wrapper +} + +/** The running/stopped tally badges are the only elements carrying these two background classes. */ +const badge = (w: ReturnType, cls: string) => w.find(`span.${cls}`).text() + +describe('NodeServicesPanel status tally ignores prototype keys (#17497)', () => { + beforeEach(() => { h.handler = null; h.getNodeServices.mockReset() }) + + it.each(['constructor', 'toString', '__proto__', 'hasOwnProperty'])( + 'a fleet-API status of %s does not change the counts', + async (status) => { + const wrapper = await mountPanel([svc('a', 'running'), svc('b', status)]) + expect(wrapper.text()).not.toContain('NaN') + expect(badge(wrapper, 'bg-green-100')).toBe('1') + }, + ) + + it.each(['constructor', 'toString', '__proto__'])( + 'a WebSocket status-update of %s leaves the tally unchanged', + async (status) => { + const wrapper = await mountPanel([svc('a', 'running'), svc('b', 'stopped')]) + ;(h.handler as unknown as StatusHandler)('n1', { service_name: 'b', status, success: true }) + await flushPromises() + expect(wrapper.text()).not.toContain('NaN') + // b's status is no longer a known one, so it drops out of the tally rather than corrupting it. + expect(badge(wrapper, 'bg-gray-100')).toBe('0') + expect(badge(wrapper, 'bg-green-100')).toBe('1') + }, + ) + + it.each(['constructor', 'toString', '__proto__'])( + 'a row with status %s gets the unknown styling, not an inherited member', + async (status) => { + const wrapper = await mountPanel([svc('b', status)]) + const row = wrapper.find('div.bg-yellow-50') + expect(row.exists()).toBe(true) + expect(row.classes()).toContain('text-yellow-700') + }, + ) +}) diff --git a/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.vue b/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.vue index b93b9872d2..0bebe070d8 100644 --- a/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.vue +++ b/autobot-slm-frontend/src/components/fleet/NodeServicesPanel.vue @@ -105,7 +105,8 @@ const filteredServices = computed(() => { const statusCounts = computed(() => { const counts = { running: 0, stopped: 0, failed: 0, unknown: 0 } services.value.forEach(s => { - if (s.status in counts) { + // Own keys only: `in` also admits `constructor`/`toString`/`__proto__` from a network payload (#17497). + if (Object.prototype.hasOwnProperty.call(counts, s.status)) { counts[s.status as keyof typeof counts]++ } }) @@ -143,7 +144,7 @@ function getStatusClasses(status: ServiceStatus): { bg: string; text: string; do stopping: { bg: 'bg-blue-50', text: 'text-blue-700', dot: 'bg-blue-500' }, completed: { bg: 'bg-gray-50', text: 'text-gray-600', dot: 'bg-gray-400' }, } - return classes[status] || classes.unknown + return Object.prototype.hasOwnProperty.call(classes, status) ? classes[status] : classes.unknown } // #13138: `memory_bytes` is optional AND nullable in the contract; the body diff --git a/autobot-slm-frontend/src/composables/useOrchestrationManagement.ts b/autobot-slm-frontend/src/composables/useOrchestrationManagement.ts index da541378e9..833d440f12 100644 --- a/autobot-slm-frontend/src/composables/useOrchestrationManagement.ts +++ b/autobot-slm-frontend/src/composables/useOrchestrationManagement.ts @@ -17,6 +17,7 @@ import { ref, computed, readonly, reactive } from 'vue' import { makeAxiosCompatClient } from '@/utils/slmApiCompat' +import { errorText } from '@/utils/errorText' import { useFleetStore } from '@/stores/fleet' import { useSlmWebSocket } from '@/composables/useSlmWebSocket' import { createLogger } from '@autobot/ui' @@ -241,11 +242,8 @@ export function useOrchestrationManagement() { // status + body are logged and the text status is dropped. const httpError = e as { response?: { status?: number; data?: unknown } } if (httpError?.response?.status !== undefined) { - logger.error('Fleet services API error:', { - status: httpError.response.status, - data: httpError.response.data, - message: e instanceof Error ? e.message : String(e), - }) + const { status, data } = httpError.response + logger.error('Fleet services API error:', { status, data, message: errorText(e) }) } else { logger.error('Failed to fetch fleet services:', e) } diff --git a/autobot-slm-frontend/src/locales/ar.json b/autobot-slm-frontend/src/locales/ar.json index e90a81b54d..530fba0338 100644 --- a/autobot-slm-frontend/src/locales/ar.json +++ b/autobot-slm-frontend/src/locales/ar.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "خطأ غير معروف" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "نظرة عامة", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/de.json b/autobot-slm-frontend/src/locales/de.json index 6157cff114..62dc5aa901 100644 --- a/autobot-slm-frontend/src/locales/de.json +++ b/autobot-slm-frontend/src/locales/de.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Unbekannter Fehler" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Übersicht", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/en.json b/autobot-slm-frontend/src/locales/en.json index e63b3fa28a..f6f8dec340 100644 --- a/autobot-slm-frontend/src/locales/en.json +++ b/autobot-slm-frontend/src/locales/en.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Unknown error" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Overview", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/es.json b/autobot-slm-frontend/src/locales/es.json index 6e119ef1e0..968affab12 100644 --- a/autobot-slm-frontend/src/locales/es.json +++ b/autobot-slm-frontend/src/locales/es.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Error desconocido" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Resumen", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/fa.json b/autobot-slm-frontend/src/locales/fa.json index 99609d76b7..f2e11e2f07 100644 --- a/autobot-slm-frontend/src/locales/fa.json +++ b/autobot-slm-frontend/src/locales/fa.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "خطای ناشناخته" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "نمای کلی", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/fr.json b/autobot-slm-frontend/src/locales/fr.json index 15fe515ef7..d5b328afa0 100644 --- a/autobot-slm-frontend/src/locales/fr.json +++ b/autobot-slm-frontend/src/locales/fr.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Erreur inconnue" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Aperçu", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/he.json b/autobot-slm-frontend/src/locales/he.json index d283f9b58e..feec504b1b 100644 --- a/autobot-slm-frontend/src/locales/he.json +++ b/autobot-slm-frontend/src/locales/he.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "שגיאה בלתי ידועה" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "סקירה", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/lv.json b/autobot-slm-frontend/src/locales/lv.json index 7958eb228a..ea7b590dd3 100644 --- a/autobot-slm-frontend/src/locales/lv.json +++ b/autobot-slm-frontend/src/locales/lv.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Nezināma kļūda" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Pārskats", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/orchestrationTabs.test.ts b/autobot-slm-frontend/src/locales/orchestrationTabs.test.ts new file mode 100644 index 0000000000..6f50efe876 --- /dev/null +++ b/autobot-slm-frontend/src/locales/orchestrationTabs.test.ts @@ -0,0 +1,47 @@ +// Copyright 2025-2026 mrveiss +// SPDX-License-Identifier: Apache-2.0 +// AutoBot - AI-Powered Automation Platform +// Author: mrveiss + +/** + * #17487: the tab id, route and key are all "infrastructure", so the label must name the + * infrastructure tab, not "Overview" (the key name is the only hint a translator gets). + */ + +import { describe, it, expect } from 'vitest' + +const bundles = import.meta.glob('./*.json', { eager: true, import: 'default' }) as Record< + string, + { orchestrationView: Record } +> + +/** What each locale held before the fix: its own translation of "Overview" (#17487). */ +const OLD_OVERVIEW: Record = { + './ar.json': 'نظرة عامة', + './de.json': 'Übersicht', + './en.json': 'Overview', + './es.json': 'Resumen', + './fa.json': 'نمای کلی', + './fr.json': 'Aperçu', + './he.json': 'סקירה', + './lv.json': 'Pārskats', + './pl.json': 'Przegląd', + './pt.json': 'Visão geral', + './ur.json': 'جائزہ', +} + +describe('orchestrationView.tabInfrastructure (#17487)', () => { + it('reads "Infrastructure" in English', () => { + expect(bundles['./en.json'].orchestrationView.tabInfrastructure).toBe('Infrastructure') + }) + + it('every locale bundle has a recorded old value, so none escapes the check', () => { + expect(Object.keys(bundles).sort()).toEqual(Object.keys(OLD_OVERVIEW).sort()) + }) + + it.each(Object.keys(OLD_OVERVIEW))('%s no longer carries its own "Overview" wording', (file) => { + const v = bundles[file].orchestrationView.tabInfrastructure + expect(v).toBeTruthy() + expect(v).not.toBe(OLD_OVERVIEW[file]) + }) +}) diff --git a/autobot-slm-frontend/src/locales/pl.json b/autobot-slm-frontend/src/locales/pl.json index af65bf239b..cfa3461b31 100644 --- a/autobot-slm-frontend/src/locales/pl.json +++ b/autobot-slm-frontend/src/locales/pl.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Nieznany błąd" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Przegląd", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/pt.json b/autobot-slm-frontend/src/locales/pt.json index eb5ce0cd62..0c9108fdb8 100644 --- a/autobot-slm-frontend/src/locales/pt.json +++ b/autobot-slm-frontend/src/locales/pt.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "Erro desconhecido" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "Visão geral", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/locales/ur.json b/autobot-slm-frontend/src/locales/ur.json index 277bcfce28..cd404a0dc2 100644 --- a/autobot-slm-frontend/src/locales/ur.json +++ b/autobot-slm-frontend/src/locales/ur.json @@ -496,7 +496,8 @@ }, "errors": { "withStatus": "{message} (HTTP {status})", - "withCause": "{message}: {cause}" + "withCause": "{message}: {cause}", + "unknown": "نامعلوم خطا" } }, "deploymentLogViewer": { @@ -891,7 +892,6 @@ "nPUWorkerMonitor": { "avgUtilization": "Avg utilization:", "currentTask": "Current Task", - "metricsUnavailable": "NPU fleet metrics are unavailable", "noNPUWorkers": "No NPU Workers", "noNodesWithThe": "No nodes with the npu-worker role are registered in the fleet.", "online": "online", @@ -2039,7 +2039,7 @@ "targetPath": "Target Path *", "targetPath2": "Target path:", "tabFleet": "Fleet Operations", - "tabInfrastructure": "جائزہ", + "tabInfrastructure": "Infrastructure", "tabMigration": "Migration", "tabPerNode": "Per-Node Control", "tabReplication": "Replication", diff --git a/autobot-slm-frontend/src/stores/fleet.npuFailures.test.ts b/autobot-slm-frontend/src/stores/fleet.npuFailures.test.ts new file mode 100644 index 0000000000..1f7bde0084 --- /dev/null +++ b/autobot-slm-frontend/src/stores/fleet.npuFailures.test.ts @@ -0,0 +1,58 @@ +// Copyright 2025-2026 mrveiss +// SPDX-License-Identifier: Apache-2.0 +// AutoBot - AI-Powered Automation Platform +// Author: mrveiss + +/** + * #19068: a rejected NPU read is a failure the caller sees, never `null` data that renders + * as "this node has no config or metrics". The store also keeps the message in `error`. + */ + +import { describe, it, expect, vi, beforeEach } from 'vitest' +import { createPinia, setActivePinia } from 'pinia' +import { useFleetStore } from './fleet' + +const api = vi.hoisted(() => ({ + getNpuStatus: vi.fn(), + getNpuLoadBalancing: vi.fn(), + getNpuFleetMetrics: vi.fn(), + getNpuNodeMetrics: vi.fn(), + getNpuWorkerConfig: vi.fn(), +})) + +vi.mock('@/composables/useSlmApi', () => ({ useSlmApi: () => api })) + +describe('fleet store NPU reads report failure (#19068)', () => { + beforeEach(() => { + setActivePinia(createPinia()) + Object.values(api).forEach((m) => m.mockReset()) + }) + + const cases = [ + ['fetchNpuStatus', 'getNpuStatus', ['n1']], + ['fetchNpuLoadBalancing', 'getNpuLoadBalancing', []], + ['fetchNpuFleetMetrics', 'getNpuFleetMetrics', []], + ['fetchNpuNodeMetrics', 'getNpuNodeMetrics', ['n1']], + ['fetchNpuWorkerConfig', 'getNpuWorkerConfig', ['n1']], + ] as const + + it.each(cases)('%s rejects and records the error when the API call fails', async (action, apiFn, args) => { + api[apiFn].mockRejectedValue(new Error('backend down')) + const store = useFleetStore() + const run = (store[action] as (...a: string[]) => Promise)(...args) + await expect(run).rejects.toThrow('backend down') + expect(store.error).toBe('backend down') + }) + + it.each(cases)('%s keeps a non-Error rejection as text, with no invented message', async (action, apiFn, args) => { + api[apiFn].mockRejectedValue('gateway timeout') + const store = useFleetStore() + await expect((store[action] as (...a: string[]) => Promise)(...args)).rejects.toBe('gateway timeout') + expect(store.error).toBe('gateway timeout') + }) + + it('returns the data on success', async () => { + api.getNpuWorkerConfig.mockResolvedValue({ priority: 3 }) + expect(await useFleetStore().fetchNpuWorkerConfig('n1')).toEqual({ priority: 3 }) + }) +}) diff --git a/autobot-slm-frontend/src/stores/fleet.ts b/autobot-slm-frontend/src/stores/fleet.ts index 0c761d4cd4..d05bcb80d8 100644 --- a/autobot-slm-frontend/src/stores/fleet.ts +++ b/autobot-slm-frontend/src/stores/fleet.ts @@ -38,6 +38,7 @@ import type { } from '@/types/slm' import { useSlmApi } from '@/composables/useSlmApi' import i18n from '@/i18n' +import { errorText } from '@/utils/errorText' import { PartialListError } from '@/utils/fetchAllPages' import { incompleteOf, reconcileUpdateSummary, toNodeMap } from './fleetHelpers' import type { NodeListIncomplete } from './fleetHelpers' @@ -211,7 +212,7 @@ export const useFleetStore = defineStore('fleet', () => { availableRoles.value = roles return roles } catch (err) { - error.value = err instanceof Error ? err.message : 'Failed to fetch roles' + error.value = errorText(err) throw err } } @@ -264,7 +265,7 @@ export const useFleetStore = defineStore('fleet', () => { return node } catch (err) { - error.value = err instanceof Error ? err.message : `Failed to refresh node ${nodeId}` + error.value = errorText(err) throw err } } @@ -359,7 +360,7 @@ export const useFleetStore = defineStore('fleet', () => { nodes.value.set(node.node_id, node) return node } catch (err) { - error.value = err instanceof Error ? err.message : 'Failed to register node' + error.value = errorText(err) throw err } } @@ -372,7 +373,7 @@ export const useFleetStore = defineStore('fleet', () => { await api.deleteNode(nodeId) removeNodeLocal(nodeId) } catch (err) { - error.value = err instanceof Error ? err.message : `Failed to delete node ${nodeId}` + error.value = errorText(err) throw err } } @@ -395,7 +396,7 @@ export const useFleetStore = defineStore('fleet', () => { return updatedNode } catch (err) { - error.value = err instanceof Error ? err.message : `Failed to update node ${nodeId}` + error.value = errorText(err) throw err } } @@ -418,7 +419,7 @@ export const useFleetStore = defineStore('fleet', () => { return updatedNode } catch (err) { - error.value = err instanceof Error ? err.message : `Failed to update roles for node ${nodeId}` + error.value = errorText(err) throw err } } @@ -445,7 +446,7 @@ export const useFleetStore = defineStore('fleet', () => { // If refresh also fails, set to unhealthy updateNodeStatus(nodeId, 'unhealthy') }) - error.value = err instanceof Error ? err.message : `Failed to enroll node ${nodeId}` + error.value = errorText(err) throw err } } @@ -468,7 +469,7 @@ export const useFleetStore = defineStore('fleet', () => { }) return result } catch (err) { - error.value = err instanceof Error ? err.message : `Failed to test connection to node ${nodeId}` + error.value = errorText(err) throw err } } @@ -486,9 +487,7 @@ export const useFleetStore = defineStore('fleet', () => { certificateStatus.value.set(nodeId, certInfo) return certInfo } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to get certificate status for node ${nodeId}` + error.value = errorText(err) throw err } } @@ -502,9 +501,7 @@ export const useFleetStore = defineStore('fleet', () => { // Refresh certificate status after renewal await checkNodeCertificate(nodeId) } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to renew certificate for node ${nodeId}` + error.value = errorText(err) throw err } } @@ -518,9 +515,7 @@ export const useFleetStore = defineStore('fleet', () => { // Refresh certificate status after deployment await checkNodeCertificate(nodeId) } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to deploy certificate to node ${nodeId}` + error.value = errorText(err) throw err } } @@ -541,9 +536,7 @@ export const useFleetStore = defineStore('fleet', () => { nodeEvents.value.set(nodeId, events) return events } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to get events for node ${nodeId}` + error.value = errorText(err) throw err } } @@ -567,9 +560,7 @@ export const useFleetStore = defineStore('fleet', () => { reconcileNodeUpdateSummary(nodeId, result.total, result.code_update_available, result.code_status) return result } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to check updates for node ${nodeId}` + error.value = errorText(err) throw err } } @@ -595,9 +586,7 @@ export const useFleetStore = defineStore('fleet', () => { failed: result.failed_updates, } } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to apply updates to node ${nodeId}` + error.value = errorText(err) throw err } } @@ -620,9 +609,7 @@ export const useFleetStore = defineStore('fleet', () => { } return npuStatuses } catch (err) { - error.value = err instanceof Error - ? err.message - : 'Failed to fetch NPU nodes' + error.value = errorText(err) return [] } } @@ -630,16 +617,14 @@ export const useFleetStore = defineStore('fleet', () => { /** * Fetch NPU status for a specific node */ - async function fetchNpuStatus(nodeId: string): Promise { + async function fetchNpuStatus(nodeId: string): Promise { try { const status = await api.getNpuStatus(nodeId) npuCapabilities.value.set(nodeId, status) return status } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to fetch NPU status for node ${nodeId}` - return null + error.value = errorText(err) + throw err } } @@ -672,9 +657,7 @@ export const useFleetStore = defineStore('fleet', () => { } return result.success } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to trigger NPU detection for node ${nodeId}` + error.value = errorText(err) return false } } @@ -717,9 +700,7 @@ export const useFleetStore = defineStore('fleet', () => { return updatedNode } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to assign NPU role to node ${nodeId}` + error.value = errorText(err) throw err } } @@ -753,9 +734,7 @@ export const useFleetStore = defineStore('fleet', () => { return updatedNode } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to remove NPU role from node ${nodeId}` + error.value = errorText(err) throw err } } @@ -770,9 +749,7 @@ export const useFleetStore = defineStore('fleet', () => { await api.updateNpuLoadBalancing(config) npuLoadBalancingConfig.value = config } catch (err) { - error.value = err instanceof Error - ? err.message - : 'Failed to update NPU load balancing configuration' + error.value = errorText(err) throw err } } @@ -780,16 +757,14 @@ export const useFleetStore = defineStore('fleet', () => { /** * Fetch current NPU load balancing configuration */ - async function fetchNpuLoadBalancing(): Promise { + async function fetchNpuLoadBalancing(): Promise { try { const config = await api.getNpuLoadBalancing() npuLoadBalancingConfig.value = config return config } catch (err) { - error.value = err instanceof Error - ? err.message - : 'Failed to fetch NPU load balancing configuration' - return null + error.value = errorText(err) + throw err } } @@ -800,44 +775,38 @@ export const useFleetStore = defineStore('fleet', () => { /** Per-node config cache */ const npuWorkerConfigs = ref>(new Map()) - async function fetchNpuFleetMetrics(): Promise { + async function fetchNpuFleetMetrics(): Promise { try { const metrics = await api.getNpuFleetMetrics() npuFleetMetrics.value = metrics return metrics } catch (err) { - error.value = err instanceof Error - ? err.message - : 'Failed to fetch NPU fleet metrics' - return null + error.value = errorText(err) + throw err } } async function fetchNpuNodeMetrics( nodeId: string - ): Promise { + ): Promise { try { return await api.getNpuNodeMetrics(nodeId) } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to fetch metrics for node ${nodeId}` - return null + error.value = errorText(err) + throw err } } async function fetchNpuWorkerConfig( nodeId: string - ): Promise { + ): Promise { try { const config = await api.getNpuWorkerConfig(nodeId) npuWorkerConfigs.value.set(nodeId, config) return config } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to fetch config for node ${nodeId}` - return null + error.value = errorText(err) + throw err } } @@ -852,9 +821,7 @@ export const useFleetStore = defineStore('fleet', () => { } return result.success } catch (err) { - error.value = err instanceof Error - ? err.message - : `Failed to update config for node ${nodeId}` + error.value = errorText(err) return false } } diff --git a/autobot-slm-frontend/src/utils/errorText.test.ts b/autobot-slm-frontend/src/utils/errorText.test.ts new file mode 100644 index 0000000000..f9de2951e1 --- /dev/null +++ b/autobot-slm-frontend/src/utils/errorText.test.ts @@ -0,0 +1,33 @@ +// Copyright 2025-2026 mrveiss +// SPDX-License-Identifier: Apache-2.0 +// AutoBot - AI-Powered Automation Platform +// Author: mrveiss + +import { describe, it, expect } from 'vitest' +import { errorText } from './errorText' + +describe('errorText (#19068)', () => { + it('returns an Error message', () => expect(errorText(new Error('boom'))).toBe('boom')) + it('returns a string as it is', () => expect(errorText('gateway timeout')).toBe('gateway timeout')) + it('renders an object as JSON, never [object Object]', () => { + expect(errorText({ code: 502 })).toBe('{"code":502}') + expect(errorText({ code: 502 })).not.toContain('[object Object]') + }) + it.each([ + ['an Error with an empty message', new Error('')], + ['null', null], + ['undefined', undefined], + ['an empty string', ''], + ['an empty object', {}], + ])('%s gives the passed fallback, not empty text', (_label, value) => { + expect(errorText(value, 'translated fallback')).toBe('translated fallback') + }) + it('defaults the fallback to the shared translated key', () => { + expect(errorText(undefined)).toBe('Unknown error') + }) + it('survives a circular object', () => { + const a: Record = {} + a.self = a + expect(errorText(a, 'fb')).toBe('fb') + }) +}) diff --git a/autobot-slm-frontend/src/utils/errorText.ts b/autobot-slm-frontend/src/utils/errorText.ts new file mode 100644 index 0000000000..2aae5823be --- /dev/null +++ b/autobot-slm-frontend/src/utils/errorText.ts @@ -0,0 +1,28 @@ +// Copyright 2025-2026 mrveiss +// SPDX-License-Identifier: Apache-2.0 +// AutoBot - AI-Powered Automation Platform +// Author: mrveiss + +import i18n from '@/i18n' + +/** JSON text of a value, or '' when it carries nothing readable (undefined, null, `{}`, circular). */ +function jsonText(value: unknown): string { + try { + const text = JSON.stringify(value) + return typeof text === 'string' && text !== 'null' && text !== '{}' ? text : '' + } catch { + return '' + } +} + +/** + * Readable text for a caught value; never "[object Object]" and never empty (#19068). + * An Error's non-empty message, a non-empty string as is, any other value as JSON, else the + * translated `fallback`. As with `autobotApiErrorMessage`, the fallback is translated text + * supplied by the caller; the default is the shared `common.errors.unknown`. + */ +export function errorText(err: unknown, fallback: string = i18n.global.t('common.errors.unknown')): string { + if (err instanceof Error) return err.message.length > 0 ? err.message : fallback + if (typeof err === 'string') return err.length > 0 ? err : fallback + return jsonText(err) || fallback +} diff --git a/autobot-slm-frontend/src/utils/fetchAllPages.ts b/autobot-slm-frontend/src/utils/fetchAllPages.ts index e674ae7bf4..8a9040a475 100644 --- a/autobot-slm-frontend/src/utils/fetchAllPages.ts +++ b/autobot-slm-frontend/src/utils/fetchAllPages.ts @@ -11,6 +11,8 @@ * caller of the node list goes through. */ +import { errorText } from './errorText' + /** The backend's per-page ceiling for node listing (`le=100`): the largest single request allowed. */ export const MAX_PAGE_SIZE = 100 @@ -33,7 +35,7 @@ export class PartialListError extends Error { readonly reason: string constructor(items: T[], total: number | null, cause: unknown) { - const reason = cause instanceof Error ? cause.message : String(cause) + const reason = errorText(cause) super(`Loaded ${items.length} of ${total ?? 'an unknown number'}: ${reason}`) this.name = 'PartialListError' this.items = items diff --git a/autobot-slm-frontend/src/views/BackupsView.vue b/autobot-slm-frontend/src/views/BackupsView.vue index 725a988d14..2d1612a0b7 100644 --- a/autobot-slm-frontend/src/views/BackupsView.vue +++ b/autobot-slm-frontend/src/views/BackupsView.vue @@ -19,6 +19,7 @@ import { useSlmApi } from '@/composables/useSlmApi' import { useFleetStore } from '@/stores/fleet' import { formatFleetDateTime } from '@/composables/useTimezone' import { useToast } from '@/composables/useToast' +import { errorText } from '@/utils/errorText' import { useI18n } from 'vue-i18n' import type { Backup, BackupRequest } from '@/types/slm' import { BaseModal, formatBytes } from '@autobot/ui' @@ -112,10 +113,6 @@ async function handleDeleteBackup(backupId: string): Promise { } } -function errorText(e: unknown): string { - return e instanceof Error ? e.message : 'Unknown error' -} - // ============================================================================= // Utilities // ============================================================================= diff --git a/autobot-slm-frontend/src/views/DeploymentsView.vue b/autobot-slm-frontend/src/views/DeploymentsView.vue index 8d2c122d49..9ea2cccda2 100644 --- a/autobot-slm-frontend/src/views/DeploymentsView.vue +++ b/autobot-slm-frontend/src/views/DeploymentsView.vue @@ -15,6 +15,7 @@ import { useSlmApi } from '@/composables/useSlmApi' import { useSlmWebSocket } from '@/composables/useSlmWebSocket' import { useFleetStore } from '@/stores/fleet' import { formatFleetDateTime } from '@/composables/useTimezone' +import { errorText } from '@/utils/errorText' import type { Deployment, BlueGreenDeployment, BlueGreenDeploymentCreate, BlueGreenStatus, NodeRole } from '@/types/slm' import { BaseAlert, BaseModal, useToast, createLogger } from '@autobot/ui' import { useI18n } from 'vue-i18n' @@ -397,9 +398,8 @@ async function handleCreateBgDeployment(): Promise { await fetchBgDeployments() } catch (err: unknown) { logger.error('Failed to create blue-green deployment:', err) - const errorMessage = err instanceof Error ? err.message : String(err) const axiosError = err as { response?: { data?: { detail?: string }; status?: number } } - const detail = axiosError?.response?.data?.detail || errorMessage + const detail = axiosError?.response?.data?.detail || errorText(err) const status = axiosError?.response?.status if (status === 403) { showToast(t('deploymentsView.accessDeniedBlueGreenDeploymentsRequireAdmin'), 'error') @@ -532,9 +532,8 @@ async function handleCreateDeployment(): Promise { fetchRoleOwners() } catch (err: unknown) { logger.error('Failed to create deployment:', err) - const errorMessage = err instanceof Error ? err.message : String(err) const axiosError = err as { response?: { data?: { detail?: string } } } - const detail = axiosError?.response?.data?.detail || errorMessage + const detail = axiosError?.response?.data?.detail || errorText(err) showToast(t('deploymentsView.failedToCreateDeployment', { detail }), 'error') } finally { isCreatingDeployment.value = false diff --git a/autobot-slm-frontend/src/views/monitoring/AlertsMonitor.vue b/autobot-slm-frontend/src/views/monitoring/AlertsMonitor.vue index f951a3e1d0..f6b5a5955f 100644 --- a/autobot-slm-frontend/src/views/monitoring/AlertsMonitor.vue +++ b/autobot-slm-frontend/src/views/monitoring/AlertsMonitor.vue @@ -15,6 +15,7 @@ import { PollingPausedAlert, createLogger, createDateFormatter, createRecencyFor import { throwUnlessLoaded, useDashboardPoller } from '@/composables/useDashboardPoller' import { useFleetMetrics } from '@/composables/useFleetMetrics' import { slmApiClient } from '@/utils/ApiClient' +import { errorText } from '@/utils/errorText' const logger = createLogger('AlertsMonitor') @@ -145,7 +146,7 @@ async function clearAlerts() { await refresh() } catch (e) { logger.error('Failed to clear alerts:', e) - clearError.value = e instanceof Error ? e.message : String(e) + clearError.value = errorText(e) } finally { isClearing.value = false } diff --git a/autobot-slm-frontend/src/views/monitoring/LogViewer.vue b/autobot-slm-frontend/src/views/monitoring/LogViewer.vue index 71fc9c3da4..d3688363d3 100644 --- a/autobot-slm-frontend/src/views/monitoring/LogViewer.vue +++ b/autobot-slm-frontend/src/views/monitoring/LogViewer.vue @@ -16,6 +16,7 @@ import { throwUnlessLoaded, useDashboardPoller } from '@/composables/useDashboar import { useSlmApi } from '@/composables/useSlmApi' import { useFleetStore } from '@/stores/fleet' import { getTimezoneOption } from '@/composables/useTimezone' +import { errorText } from '@/utils/errorText' import type { AppLogEntry } from '@/types/api-responses' const logger = createLogger('LogViewer') @@ -129,7 +130,7 @@ async function fetchLogs(): Promise { } catch (err) { // #19887: keep the last good rows; a failed read is not an empty result logger.error('Failed to fetch logs:', err) - logLoadError.value = err instanceof Error ? err.message : String(err) + logLoadError.value = errorText(err) return false } finally { isLoading.value = false @@ -211,7 +212,7 @@ async function fetchAppLogs() { logger.error('Failed to fetch application logs:', err) appLogEntries.value = [] appLogTotal.value = 0 - appLogError.value = err instanceof Error ? err.message : String(err) + appLogError.value = errorText(err) } finally { isAppLogLoading.value = false }