Skip to content

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

TypeScript

fix(mcp-host): derive Vertex/Bedrock 404 fixtures from real SDK constructors (R2-B1)

Diego Zacarias3746a54de136
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 8a35a59c2..df150f9ed 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.241",
+ "version": "0.1.242",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.241",
+ "version": "0.1.242",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index af4bc1034..eec8a01de 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.241",
+ "version": "0.1.242",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/llm/__tests__/modelNotAvailable.observable.test.ts b/mcp-host/src/llm/__tests__/modelNotAvailable.observable.test.ts
index 53069ebf6..82933e400 100644
--- a/mcp-host/src/llm/__tests__/modelNotAvailable.observable.test.ts
+++ b/mcp-host/src/llm/__tests__/modelNotAvailable.observable.test.ts
@@ -29,7 +29,12 @@ import { FailoverEngine } from '../failover/engine'
import type { LlmPolicy, ModelPair } from '../failover/types'
import { OpenAICompatibleProvider } from '../openaiCompatible'
import type { ClassifiedError } from '../types'
-import { anthropicApiError, openaiApiError } from './sdkErrorFixtures'
+import {
+ anthropicApiError,
+ bedrockResourceNotFound,
+ openaiApiError,
+ vertexApiError,
+} from './sdkErrorFixtures'
const PRIMARY: ModelPair = { provider: 'claude', model: 'claude-sonnet-4-6' }
@@ -50,10 +55,11 @@ const zai = new OpenAICompatibleProvider(
const claude = new ClaudeProvider('fake-key', 'claude-sonnet-4-6')
// Real SDK-shaped 404 payloads (the boundary these classifiers consume), one
-// per arm. The OpenAI/Anthropic arms derive from their SDK error constructors
-// (T1); Vertex/Bedrock use plain GCP/AWS-shaped errors (their producers are not
-// exposed SDK error classes). The ClassifiedError/LlmError below are produced
-// by the real classifiers, not hand-written.
+// per arm. All four arms derive from the real SDK error constructor (T1):
+// OpenAI/Anthropic via `*.APIError.generate`, Vertex via `new ApiError`
+// (@google/genai), Bedrock via `new ResourceNotFoundException`
+// (@aws-sdk/client-bedrock-runtime). The ClassifiedError/LlmError below are
+// produced by the real classifiers, not hand-written.
const CASES: ReadonlyArray<[string, Classifier, string, unknown]> = [
[
'openai-compat (zai)',
@@ -71,17 +77,15 @@ const CASES: ReadonlyArray<[string, Classifier, string, unknown]> = [
'vertex (google)',
classifyGoogleError,
'vertex',
- { status: 404, message: 'Publisher Model `x` was not found' },
+ vertexApiError(404, {
+ error: { code: 404, message: 'Publisher Model `x` was not found', status: 'NOT_FOUND' },
+ }),
],
[
'bedrock',
classifyBedrockError,
'bedrock',
- {
- name: 'ResourceNotFoundException',
- message: 'The provided model identifier is invalid',
- $metadata: { httpStatusCode: 404 },
- },
+ bedrockResourceNotFound('The provided model identifier is invalid'),
],
]
diff --git a/mcp-host/src/llm/__tests__/sdkErrorFixtures.ts b/mcp-host/src/llm/__tests__/sdkErrorFixtures.ts
index 57c27adb5..c295efff5 100644
--- a/mcp-host/src/llm/__tests__/sdkErrorFixtures.ts
+++ b/mcp-host/src/llm/__tests__/sdkErrorFixtures.ts
@@ -1,19 +1,25 @@
/**
* Test fixtures DERIVED from the real provider SDK error constructors (T1) —
- * never hand-built object literals. This matters because the two SDKs nest the
+ * never hand-built object literals. This matters because the SDKs shape the
* error body differently, and hand-writing the shape encodes a belief about
- * that nesting rather than the truth:
+ * that shape rather than the truth:
*
* - `Anthropic.APIError.generate(...)` stores the FULL response envelope on
* `.error` → `{ type:'error', error:{ type, message } }` (modeled type at
* `.error.error.type`).
* - `OpenAI.APIError.generate(...)` stores only the INNER error object on
* `.error` → `{ code, message, type }` (code at `.error.code`).
+ * - `new ApiError(...)` (`@google/genai`) is FLAT: numeric `.status` plus a
+ * stringified `.message` envelope, no structured gRPC status field.
+ * - `new ResourceNotFoundException(...)` (`@aws-sdk/client-bedrock-runtime`)
+ * fixes `.name` and `$fault`, exposing `.message` and `.$metadata`.
*
* Deriving from the producers guarantees the classifiers under test consume the
* exact shape the SDKs emit.
*/
import Anthropic from '@anthropic-ai/sdk'
+import { ResourceNotFoundException } from '@aws-sdk/client-bedrock-runtime'
+import { ApiError } from '@google/genai'
import OpenAI from 'openai'
/**
@@ -47,3 +53,37 @@ export function openaiApiError(
{}
)
}
+
+/**
+ * A real `@google/genai` `ApiError` as thrown by the Vertex driver's SDK. The
+ * SDK's throw path constructs it as `new ApiError({ status, message })` where
+ * `message` is `JSON.stringify(errorBody)` — the whole HTTP error envelope
+ * (e.g. `{"error":{"code":404,"message":"...","status":"NOT_FOUND"}}`).
+ *
+ * `ApiError` is FLAT: it carries only a numeric `.status` and the stringified
+ * `.message`. It does NOT expose the nested gRPC `status` string
+ * (`error.status: 'NOT_FOUND'`) as a structured field — that lives buried
+ * inside `.message`. So `classifyGoogleError`, which reads `providerCode` only
+ * from structured fields (`e.status`/`e.code`/`e.error?.status`), sees no gRPC
+ * status string and leaves `providerCode` undefined — exactly as with the real
+ * producer.
+ */
+export function vertexApiError(status: number, envelope: object): unknown {
+ return new ApiError({ status, message: JSON.stringify(envelope) })
+}
+
+/**
+ * A real `@aws-sdk/client-bedrock-runtime` `ResourceNotFoundException` as the
+ * Bedrock Converse client throws for a retired/invalid model id. The class
+ * fixes `name === 'ResourceNotFoundException'` and `$fault === 'client'`
+ * internally; the constructor opts only carry `{ message, $metadata }` (all
+ * other base-exception fields are excluded by the SDK's `ExceptionOptionType`).
+ * `classifyBedrockError` reads `.name` and `.$metadata.httpStatusCode`, both of
+ * which the resulting instance exposes.
+ */
+export function bedrockResourceNotFound(message: string): unknown {
+ return new ResourceNotFoundException({
+ message,
+ $metadata: { httpStatusCode: 404 },
+ })
+}