{"record":{"id":"b6f12e68043bf638","repo":"Hmbown/CodeWhale","slug":"runtime-api-thread-response-missing-id","errorCode":null,"errorMessage":"runtime API thread response missing id","messagePattern":"runtime API thread response missing id","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/app-server/src/lib.rs","lineNumber":1385,"sourceCode":"    fn drop(&mut self) {\n        self.shutdown_child();\n    }\n}\n\nfn reserve_runtime_port() -> Result<u16> {\n    let listener = std::net::TcpListener::bind(\"127.0.0.1:0\")?;\n    Ok(listener.local_addr()?.port())\n}\n\nfn install_rustls_crypto_provider() {\n    let _ = rustls::crypto::ring::default_provider().install_default();\n}\n\nfn extract_runtime_thread_id(record: &Value) -> Result<&str> {\n    record\n        .get(\"id\")\n        .and_then(Value::as_str)\n        .ok_or_else(|| anyhow!(\"runtime API thread response missing id\"))\n}\n\nfn turn_terminal_status(payload: &Value) -> TurnTerminalStatus {\n    match payload\n        .pointer(\"/turn/status\")\n        .and_then(Value::as_str)\n        .unwrap_or(\"completed\")\n        .to_ascii_lowercase()\n        .as_str()\n    {\n        \"failed\" => TurnTerminalStatus::Failed,\n        \"interrupted\" => TurnTerminalStatus::Interrupted,\n        \"canceled\" | \"cancelled\" => TurnTerminalStatus::Canceled,\n        _ => TurnTerminalStatus::Completed,\n    }\n}\n\nasync fn emit_stdio_event<W: AsyncWrite + Unpin>(writer: &mut W, event: Value) -> Result<()> {","sourceCodeStart":1367,"sourceCodeEnd":1403,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/app-server/src/lib.rs#L1367-L1403","documentation":"Contract guard in extract_runtime_thread_id: a JSON record received from the runtime API lacks a string id field, so it cannot be used as a thread reference. This is a malformed-response check on untrusted runtime output; any record without a usable id is rejected rather than defaulted.","triggerScenarios":"Thrown at crates/app-server/src/lib.rs:1385 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the request; truncated responses can transiently omit fields","Verify the runtime bridge version emits id on its thread records","Inspect the raw runtime response in logs to confirm its shape","Restart or upgrade the runtime bridge if records consistently lack ids"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}