Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): classify every causeful gfsc fetch TypeError
Alfredo Lopeza80098ff234d
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex e02db0ee6..ab09f51e8 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.465",+ "version": "0.1.466","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.465",+ "version": "0.1.466","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex b4676ce3a..eab121e9b 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.465",+ "version": "0.1.466","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/agent/__tests__/fileReferenceResolver.test.ts b/mcp-host/src/agent/__tests__/fileReferenceResolver.test.tsindex 5d4556f5f..06199df18 100644--- a/mcp-host/src/agent/__tests__/fileReferenceResolver.test.ts+++ b/mcp-host/src/agent/__tests__/fileReferenceResolver.test.ts@@ -615,6 +615,19 @@ describe('resolveFileReferences (#666)', () => {errorClass: 'TypeError',})})++ it('fails transient when gfsc base URL has a bad port', async () => {+ const authFile = join(dir, 'auth-bad-port')+ await writeBearerFile(authFile)+ // Node's fetch reports this port as a TypeError whose Error cause says+ // "bad port" and carries no code, so the code-based test cannot see it.+ const gfsc = realHttpClient(authFile, 'http://127.0.0.1:1')+ expect(await resolveFileReferences([gfsReference()], gfsc)).toEqual({+ ok: false,+ failure: 'transient',+ errorClass: 'TypeError',+ })+ })})it('names a code for every unavailable availability', () => {diff --git a/mcp-host/src/agent/fileReferenceResolver.ts b/mcp-host/src/agent/fileReferenceResolver.tsindex 69242ae1c..320d970e8 100644--- a/mcp-host/src/agent/fileReferenceResolver.ts+++ b/mcp-host/src/agent/fileReferenceResolver.ts@@ -202,17 +202,19 @@ function checkFailure(error: unknown): ResolutionFailure {return new ResolutionFailure('transient', error.name)if (error instanceof SyntaxError) return new ResolutionFailure('contract', 'SyntaxError')if (isTokenReadError(error)) return new ResolutionFailure('credentials', 'TokenReadError')- // fetch reports a refused, reset or unresolvable connection as a TypeError- // whose cause is the Node system error. With redirect:'error' it reports a- // 3xx as a TypeError whose cause says "unexpected redirect" and carries no- // code. Any other TypeError is a Host defect and falls through to the- // rethrow below.+ // fetch reports every transport or URL failure as a TypeError carrying the+ // underlying failure as its cause: a Node system error with a code, or a+ // port/address/URL failure that carries only a message ("bad port",+ // ERR_INVALID_URL). With redirect:'error' it reports a 3xx as a cause+ // saying "unexpected redirect". A TypeError without an Error cause is a+ // Host defect and falls through to the rethrow below.if (error instanceof TypeError) {const cause = (error as { cause?: unknown }).cause- if (cause instanceof Error && typeof (cause as NodeJS.ErrnoException).code === 'string')+ if (cause instanceof Error) {+ if (cause.message === 'unexpected redirect')+ return new ResolutionFailure('contract', 'TypeError')return new ResolutionFailure('transient', 'TypeError')- if (cause instanceof Error && cause.message === 'unexpected redirect')- return new ResolutionFailure('contract', 'TypeError')+ }}}throw error