{"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":null,"httpStatus":null,"severity":"error","filePath":"crates/app-server/src/lib.rs","lineNumber":2033,"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":2015,"sourceCodeEnd":2051,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/app-server/src/lib.rs#L2015-L2051","documentation":"Thrown by `extract_runtime_thread_id`, which pulls the `id` field out of a runtime API thread record and requires it to be a non-null string. If the thread response lacks `id` (or it is not a string), the client cannot key subsequent turns to the thread and raises this error. It is a response-shape guard against runtime protocol drift or malformed replies.","triggerScenarios":"Creating or resuming a thread via the runtime API and the returned JSON record has no string `id` field — e.g. an error body returned with a 200, or an API schema change.","commonSituations":"Runtime server version mismatch with the client; misconfigured base URL hitting a different service; proxies mangling responses; bug in the runtime returning partial thread objects.","solutions":["Log the raw thread response body to see what was returned instead of the expected `id`.","Confirm the runtime API version matches what this client expects.","Verify the thread endpoint/base URL points at the correct runtime service.","Return the serialized record in the error message to make future mismatches diagnosable."],"exampleFix":"// before\n.ok_or_else(|| anyhow!(\"runtime API thread response missing id\"))\n// after\n.ok_or_else(|| anyhow!(\"runtime API thread response missing id: {}\", record))","handlingStrategy":"validation","validationCode":"if record.get(\"id\").and_then(Value::as_str).is_none() {\n    // log record and abort before creating turns on this thread\n}","typeGuard":"fn has_thread_id(v: &Value) -> bool { v.get(\"id\").map_or(false, Value::is_string) }","tryCatchPattern":"match create_thread(...).await {\n    Err(e) if e.to_string().contains(\"missing id\") => { /* log raw body, verify runtime version */ }\n    other => other?,\n}","preventionTips":["Verify the thread endpoint returns a full thread object in tests","Pin runtime/client API versions","Surface raw response bodies on parse failure"],"tags":["json","api-response","missing-field"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}