Hmbown/CodeWhale · error

runtime API thread response missing id

Error message

runtime API thread response missing id

What it means

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.

Solutions

  1. Log the raw thread response body to see what was returned instead of the expected `id`.
  2. Confirm the runtime API version matches what this client expects.
  3. Verify the thread endpoint/base URL points at the correct runtime service.
  4. Return the serialized record in the error message to make future mismatches diagnosable.

Example fix

// before
.ok_or_else(|| anyhow!("runtime API thread response missing id"))
// after
.ok_or_else(|| anyhow!("runtime API thread response missing id: {}", record))
Defensive patterns

Strategy: validation

Validate before calling

if record.get("id").and_then(Value::as_str).is_none() {
    // log record and abort before creating turns on this thread
}

Type guard

fn has_thread_id(v: &Value) -> bool { v.get("id").map_or(false, Value::is_string) }

Try / catch

match create_thread(...).await {
    Err(e) if e.to_string().contains("missing id") => { /* log raw body, verify runtime version */ }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/b6f12e68043bf638. Report an issue: GitHub.

Appendix: source

Thrown at crates/app-server/src/lib.rs:2033

    fn drop(&mut self) {
        self.shutdown_child();
    }
}

fn reserve_runtime_port() -> Result<u16> {
    let listener = std::net::TcpListener::bind("127.0.0.1:0")?;
    Ok(listener.local_addr()?.port())
}

fn install_rustls_crypto_provider() {
    let _ = rustls::crypto::ring::default_provider().install_default();
}

fn extract_runtime_thread_id(record: &Value) -> Result<&str> {
    record
        .get("id")
        .and_then(Value::as_str)
        .ok_or_else(|| anyhow!("runtime API thread response missing id"))
}

fn turn_terminal_status(payload: &Value) -> TurnTerminalStatus {
    match payload
        .pointer("/turn/status")
        .and_then(Value::as_str)
        .unwrap_or("completed")
        .to_ascii_lowercase()
        .as_str()
    {
        "failed" => TurnTerminalStatus::Failed,
        "interrupted" => TurnTerminalStatus::Interrupted,
        "canceled" | "cancelled" => TurnTerminalStatus::Canceled,
        _ => TurnTerminalStatus::Completed,
    }
}

async fn emit_stdio_event<W: AsyncWrite + Unpin>(writer: &mut W, event: Value) -> Result<()> {

View on GitHub (pinned to 73e0f67d83)