decolua/9router · error
[Kiro MITM] Request processing failed: ${error.message}
Error message
[Kiro MITM] Request processing failed: ${error.message} What it means
The Kiro MITM handler forwards requests to the router and re-encodes the OpenAI SSE response into AWS EventStream binary via pipeTransformedEventStream. Any failure (router fetch, OpenAI→Kiro conversion, EventStream encoding) is logged '[Kiro MITM] Request processing failed: <message>' and returned as a 500 JSON error to the Kiro client.
Source
Thrown at src/mitm/handlers/kiro.js:522
const tools = extractTools(body);
const openaiBody = {
model: mappedModel,
messages,
stream: true,
// Forward tools so Claude uses structured tool_calls instead of XML text fallback
...(tools.length > 0 && { tools, tool_choice: "auto" }),
};
// 3: Forward to 9router
const routerRes = await fetchRouter(openaiBody, "/v1/chat/completions", req.headers);
// 4 + 5: Re-encode response as AWS EventStream binary using standard pipeline
const state = initKiroState(mappedModel);
await pipeTransformedEventStream(routerRes, res, convertOpenAIToKiro, state);
} catch (error) {
err(`[Kiro MITM] Request processing failed: ${error.message}`);
if (!res.headersSent) {
res.writeHead(500, { "Content-Type": "application/json" });
}
res.end(JSON.stringify({
error: {
message: error.message,
type: "mitm_error",
handler: "kiro"
}
}));
}
}
// Detect AWS EventStream binary format
function isBinaryEventStream(buffer) {
if (!buffer || buffer.length < 12) return false;
// AWS EventStream signature:
// - First 4 bytes: total frame length (big-endian)View on GitHub (pinned to 90b52e06ff)
Solutions
- Confirm the 9Router gateway is running and reachable at the configured router port.
- Read the logged failure message: encoding errors usually mean a Kiro client/protocol update — update 9Router.
- Verify the requested model exists in the Kiro model map / provider config.
- Retry; if it fails mid-stream repeatedly, capture the dump file and compare against a working request.
Example fix
// before: protocol mismatch convertOpenAIToKiro throws on unknown event shape → Request processing failed // after npm update 9router # pull updated Kiro EventStream translation
Defensive patterns
Strategy: try-catch
Validate before calling
const health = await fetch('http://127.0.0.1:20128/dashboard').then(r => r.ok).catch(() => false);
if (!health) throw new Error('Router gateway not reachable');
if (!modelMap[kiroModel]) throw new Error(`No model mapping for ${kiroModel}`); Try / catch
try {
const state = initKiroState(mappedModel);
await pipeTransformedEventStream(routerRes, res, convertOpenAIToKiro, state);
} catch (error) {
err(`[Kiro MITM] Request processing failed: ${error.message}`);
if (!res.headersSent) res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: { message: error.message, type: 'mitm_error' } }));
} Prevention
- Keep Kiro model mappings current with the Kiro IDE's requested model ids.
- Update 9Router when Kiro changes its EventStream framing.
- Validate gateway health before starting the MITM listener.
- Retain dump files from failed requests for protocol debugging.
When it happens
Trigger: intercept() throws during JSON parsing of the Kiro binary request, router call fails, or convertOpenAIToKiro/EventStream re-encoding encounters an unexpected chunk shape mid-stream.
Common situations: Kiro IDE pointed at the MITM host while the gateway is down; Kiro client updated its EventStream framing; a model mapping missing for the requested Kiro model.
Related errors
- Cursor AgentService endpoint is not configured
- Binary EventStream format detected (${bodyBuffer.length}B) -
- Kiro toolUseEvent is empty
- Kiro toolUseEvent is missing a tool name
- Kiro toolUseEvent has an invalid toolUseId
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/eae2bc9af1b525db.
Report an issue: GitHub.