Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): derive rejected API errors from the real formatApiError (R3-B1)
Diego Zacarias7b038789a136
diff --git a/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsx b/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsxindex c37f391ad..7e6fb9065 100644--- a/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsx+++ b/control-ui/components/__tests__/LlmModelEditImpactGate.test.tsx@@ -2,7 +2,7 @@ import type React from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import type { CreateLlmModelInput, LlmAllowedModel } from '@lib/api'-import { getLlmModel, updateLlmModel } from '@lib/api'+import { formatApiError, getLlmModel, updateLlmModel } from '@lib/api'import EditLlmModelPage from '../../app/llm-models/[id]/edit/page'const mockPush = vi.fn()@@ -57,14 +57,14 @@ vi.mock('@lib/api', async importOriginal => {return { ...actual, getLlmModel: vi.fn(), updateLlmModel: vi.fn() }})-// Mirrors the Error shape lib/api.ts formatApiError produces: message plus the-// preserved structured `.status`/`.code`/`.body` the typed helpers read.+// Derive the rejected Error from the REAL client error producer (formatApiError,+// lib/api.ts) instead of re-implementing its `.status`/`.code`/`.body` shape by+// hand (T1). A change to how control-ui represents an API error now flows into+// these tests rather than silently diverging from a hand-mirrored copy.function structuredApiError(status: number, body: Record<string, unknown>): Error {- const error = new Error(`${status} Conflict - ${String(body.error)}`)- ;(error as Error & { status?: number }).status = status- ;(error as Error & { code?: string }).code = String(body.error)- ;(error as Error & { body?: unknown }).body = body- return error+ const text = JSON.stringify(body)+ const res = new Response(text, { status, headers: { 'content-type': 'application/json' } })+ return formatApiError(res, text)}const model: LlmAllowedModel = {diff --git a/control-ui/components/__tests__/LlmModelsCatalogAttention.test.tsx b/control-ui/components/__tests__/LlmModelsCatalogAttention.test.tsxindex 7e53394a3..52e255a97 100644--- a/control-ui/components/__tests__/LlmModelsCatalogAttention.test.tsx+++ b/control-ui/components/__tests__/LlmModelsCatalogAttention.test.tsx@@ -2,7 +2,13 @@ import type { ReactNode } from 'react'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'import type { LlmAllowedModel } from '@lib/api'-import { deleteLlmModel, getAdminAttention, getLlmModels, getUnpricedModels } from '@lib/api'+import {+ deleteLlmModel,+ formatApiError,+ getAdminAttention,+ getLlmModels,+ getUnpricedModels,+} from '@lib/api'import { LlmModelsSurface } from '../LlmModelsSurface'import { ToastProvider } from '../Toast'@@ -50,14 +56,14 @@ vi.mock('@lib/api', async importOriginal => {}})-// Mirrors the Error shape lib/api.ts formatApiError produces: message plus the-// preserved structured `.status`/`.code`/`.body` the typed helpers read.+// Derive the rejected Error from the REAL client error producer (formatApiError,+// lib/api.ts) instead of re-implementing its `.status`/`.code`/`.body` shape by+// hand (T1). A change to how control-ui represents an API error now flows into+// these tests rather than silently diverging from a hand-mirrored copy.function structuredApiError(status: number, body: Record<string, unknown>): Error {- const error = new Error(`${status} Conflict - ${String(body.error)}`)- ;(error as Error & { status?: number }).status = status- ;(error as Error & { code?: string }).code = String(body.error)- ;(error as Error & { body?: unknown }).body = body- return error+ const text = JSON.stringify(body)+ const res = new Response(text, { status, headers: { 'content-type': 'application/json' } })+ return formatApiError(res, text)}const model: LlmAllowedModel = {diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 0661c711b..9a8c85f8a 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.430",+ "version": "0.1.431","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.430",+ "version": "0.1.431","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-ui/package.json b/control-ui/package.jsonindex ac5504573..6ef51ab64 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.430",+ "version": "0.1.431","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",