fix(jeb): confine an invalid REA_JEB_MCP_URL to the JEB tools (#2145)
JebProvider throws when REA_JEB_MCP_URL fails endpoint validation, and the composition built it eagerly for the CLI and every MCP connection. A malformed value, or http://localhost:8425/mcp, therefore crashed every CLI command with a stack trace and failed every MCP connection with an internal server error. The composition now parses the endpoint first and, when it is unusable, returns a JEB port that reports not_configured availability and a ConfigurationError naming REA_JEB_MCP_URL. Fixes #2143 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
58fb372071
commit
df2c08b546
@@ -30,3 +30,14 @@ it("validates decompile item input before contacting the engine", async () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("reports an invalid endpoint without breaking other commands", async () => {
|
||||
const environment = { REA_JEB_MCP_URL: "http://localhost:8425/mcp" };
|
||||
const jeb = await serveCli(["inspect-jeb-client", "--json"], environment);
|
||||
expect(JSON.parse(jeb.stdout)).toMatchObject({
|
||||
code: "configuration_invalid",
|
||||
details: { settings: [{ setting: "REA_JEB_MCP_URL" }] },
|
||||
});
|
||||
const capabilities = await serveCli(["capabilities", "--json"], environment);
|
||||
expect(capabilities.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
@@ -141,3 +141,45 @@ it("preserves JEB provider failure reasons through the MCP boundary", async () =
|
||||
expect(text).toContain("ECONNREFUSED");
|
||||
expect(text).toContain("REA_JEB_MCP_URL");
|
||||
});
|
||||
|
||||
it("keeps the MCP server usable when REA_JEB_MCP_URL is invalid", async () => {
|
||||
const session = createTestBinarySession(() => {
|
||||
throw new Error("deep provider must not start");
|
||||
});
|
||||
const server = createServer(
|
||||
{ kind: "session", session },
|
||||
{ environment: { REA_JEB_MCP_URL: "http://localhost:8425/mcp" } },
|
||||
);
|
||||
const client = new Client({ name: "jeb-invalid-endpoint", version: "1" });
|
||||
onTestFinished(async () => {
|
||||
await client.close();
|
||||
await server.close();
|
||||
await session.close();
|
||||
});
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
expect((await client.listTools()).tools.length).toBeGreaterThan(0);
|
||||
const failed = await client.callTool({
|
||||
name: "inspect_jeb_client",
|
||||
arguments: {},
|
||||
});
|
||||
expect(failed.isError).toBe(true);
|
||||
const text = (failed.content ?? [])
|
||||
.map((block) => (block.type === "text" ? block.text : ""))
|
||||
.join("");
|
||||
expect(JSON.parse(text)).toMatchObject({
|
||||
error: {
|
||||
code: "configuration_invalid",
|
||||
details: {
|
||||
settings: [
|
||||
{
|
||||
setting: "REA_JEB_MCP_URL",
|
||||
constraint: expect.stringContaining("loopback"),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user