Skip to content

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

TypeScript

fix(rpc-proxy): treat a non-204 2xx from control-api as invalid (R1-L2)

Diego Zacarias7c4d7076570a
diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.ts
index 5bf3423ed..60e2c4d2a 100644
--- a/external-rest-api/src/releaseManifest.ts
+++ b/external-rest-api/src/releaseManifest.ts
@@ -9,7 +9,7 @@ export type ReleaseManifest = {
export const releaseManifest: ReleaseManifest = {
releaseId: 'v0.7.0',
externalRestApiVersion: '0.1.81',
- rpcProxyVersion: '0.1.70',
+ rpcProxyVersion: '0.1.71',
desktopVersion: '0.7.0',
minimumDesktopVersion: '0.1.252',
}
diff --git a/rpc-proxy/package-lock.json b/rpc-proxy/package-lock.json
index 394884333..cd3d293ac 100644
--- a/rpc-proxy/package-lock.json
+++ b/rpc-proxy/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.70",
+ "version": "0.1.71",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-rpc-proxy",
- "version": "0.1.70",
+ "version": "0.1.71",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2",
diff --git a/rpc-proxy/package.json b/rpc-proxy/package.json
index 0d68e267d..2d3cf2e39 100644
--- a/rpc-proxy/package.json
+++ b/rpc-proxy/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.70",
+ "version": "0.1.71",
"description": "External-facing RPC proxy for tenant-scoped MCP access",
"main": "dist/main.js",
"engines": {
diff --git a/rpc-proxy/src/routes/mcpOauth.ts b/rpc-proxy/src/routes/mcpOauth.ts
index 34ab47d0e..ad9e8b364 100644
--- a/rpc-proxy/src/routes/mcpOauth.ts
+++ b/rpc-proxy/src/routes/mcpOauth.ts
@@ -200,9 +200,18 @@ export function createMcpOauthRouter(): Router {
return
}
- // Success: control-api answers 204 (no body). Forward it verbatim.
+ // Success is EXACTLY 204 (no body) per the internal contract. Any OTHER
+ // 2xx is an unexpected shape from control-api — coerce it to 502 rather
+ // than forwarding an ambiguous "success" the desktop can't interpret.
+ if (upstream.status === 204) {
+ res.status(204).end()
+ return
+ }
if (upstream.ok) {
- res.status(upstream.status).end()
+ console.warn(
+ `[RPC_PROXY] control-api disconnect unexpected 2xx status=${upstream.status} server=${mcpServerName}`
+ )
+ res.status(502).json({ error: 'control_api_invalid_response' })
return
}
diff --git a/rpc-proxy/src/routes/mcpOauthDisconnect.test.ts b/rpc-proxy/src/routes/mcpOauthDisconnect.test.ts
index b3133684f..93105eeef 100644
--- a/rpc-proxy/src/routes/mcpOauthDisconnect.test.ts
+++ b/rpc-proxy/src/routes/mcpOauthDisconnect.test.ts
@@ -161,4 +161,14 @@ describe('DELETE /api/v1/mcp-oauth/:mcpServerName/grant (spec 11 U4 disconnect)'
expect(res.body.error).toBe('control_api_timeout')
warnSpy.mockRestore()
})
+
+ it('coerces an unexpected 2xx (e.g. 200) from control-api to 502 (R1-L2)', async () => {
+ const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {})
+ // The internal contract is 204-on-success; a 200 is off-contract.
+ fetchSpy.mockResolvedValue(jsonResponse(200, { ok: true }))
+ const res = await request(makeApp()).delete(PATH).set('Authorization', 'Bearer t').send({})
+ expect(res.status).toBe(502)
+ expect(res.body.error).toBe('control_api_invalid_response')
+ warnSpy.mockRestore()
+ })
})