Hmbown/CodeWhale · error · anyhow::Error

Antigravity cloud-code request is missing a model id

Error message

Antigravity cloud-code request is missing a model id

What it means

The cloud-code request builder trims `request.model` and requires a non-empty result before constructing the JSON body. An empty or whitespace model id means the wire body would carry no model, which cloud-code cannot route, so the builder fails locally. This is the last structural check before the request JSON is assembled.

Source

Thrown at crates/tui/src/client/cloud_code.rs:89

                ContentBlock::Text { text, .. } if !text.trim().is_empty() => {
                    parts.push(json!({ "text": text }));
                }
                ContentBlock::Text { .. } => {}
                _ => bail!(
                    "Antigravity cloud-code accepts text parts only; non-text content fails closed"
                ),
            }
        }
        if !parts.is_empty() {
            contents.push(json!({ "role": role, "parts": parts }));
        }
    }
    if contents.is_empty() {
        bail!("Antigravity cloud-code request has no text contents");
    }
    let model = request.model.trim();
    if model.is_empty() {
        bail!("Antigravity cloud-code request is missing a model id");
    }
    Ok(json!({
        "model": model,
        "userAgent": "codewhale",
        "request": {
            "contents": contents,
        }
    }))
}

/// Pull visible text out of a cloud-code SSE JSON object. Unknown shapes
/// return `None` so the caller can fail closed instead of guessing.
pub fn extract_cloud_code_text(value: &Value) -> Option<String> {
    if let Some(text) = value.pointer("/response/candidates/0/content/parts/0/text") {
        return text.as_str().filter(|s| !s.is_empty()).map(str::to_string);
    }
    if let Some(text) = value.pointer("/candidates/0/content/parts/0/text") {
        return text.as_str().filter(|s| !s.is_empty()).map(str::to_string);

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Set an explicit model id in the provider/session config for the antigravity route
  2. Verify default-model resolution produces a non-empty id before the session starts
  3. Fail early at session creation with a clear config error instead of at request time

Example fix

// before
provider.model = ""; // -> bail at request build time

// after
provider.model = "gemini-2.5-pro";
anyhow::ensure!(!provider.model.trim().is_empty(), "antigravity provider needs a model id");
Defensive patterns

Strategy: validation

Validate before calling

anyhow::ensure!(
    !request.model.trim().is_empty(),
    "antigravity request needs a model id; check provider config"
);

Type guard

fn model_id_present(model: &str) -> bool {
    !model.trim().is_empty()
}

Try / catch

match client.create_message_stream(request).await {
    Ok(s) => Ok(s),
    Err(err) if err.to_string().contains("missing a model id") => {
        Err(fix_config_and_restart()) // config-level fix, not a retry
    }
    Err(err) => Err(err),
}

Prevention

When it happens

Trigger: `request.model` is an empty string or only whitespace when the builder runs on an antigravity route.

Common situations: Provider config missing a `model` field; default-model resolution returning an empty string silently; a session created without a model after a config refactor.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/bfca9020e8b67b57. Report an issue: GitHub.