xai-org/grok-build · error
screen query failed: {body}
Error message
screen query failed: {body} What it means
screen() queries the terminal content of a session. Non-2xx HTTP responses are converted into this error carrying the server's response body.
Source
Thrown at crates/codegen/ptyctl-cli/src/commands/client.rs:76
if let Some(r) = rows {
req = req.query(&[("rows", r)]);
}
if let Some(c) = cols {
req = req.query(&[("cols", c)]);
}
if let Some(ch) = cursor {
req = req.query(&[("cursor", &ch.to_string())]);
}
req = req.query(&[("format", format)]);
if full {
req = req.query(&[("full", "true")]);
}
let resp = req.send().await.context("failed to query screen")?;
if !resp.status().is_success() {
let body = resp.text().await.unwrap_or_default();
anyhow::bail!("screen query failed: {body}");
}
let body = resp.text().await?;
if format == "html" || format == "styled" {
println!("{body}");
} else {
// Parse as JSON and print lines.
let output: serde_json::Value = serde_json::from_str(&body)?;
if let Some(lines) = output.get("lines").and_then(|l| l.as_array()) {
for (i, line) in lines.iter().enumerate() {
let text = line.as_str().unwrap_or("");
if line_numbers {
println!("{:4} {text}", i + 1);
} else {
println!("{text}");
}
}View on GitHub (pinned to bc7f02eddd)
Solutions
- Inspect the error body for the server-side cause
- Confirm the session name/port is correct and the server is alive
- Fix invalid query parameters (format, wait/stable_ms options)
- Restart the session if it exited
Defensive patterns
Strategy: try-catch
Validate before calling
let info = registry::lookup_session(name)?; // fails fast if session unknown
Try / catch
match client.screen(target, format).await {
Ok(out) => println!("{out}"),
Err(e) if e.to_string().contains("screen query failed:") => {
eprintln!("query rejected: {e}");
}
Err(e) => return Err(e),
} Prevention
- Validate format/stable_ms parameters before querying
- Verify session name against the registry before each query
- Handle session-exited races by re-checking liveness on failure
When it happens
Trigger: GET to the session's screen endpoint returning non-2xx: session not found, session crashed, or invalid query parameters (e.g. bad format/stable_ms values).
Common situations: Polling a session in test scripts after it exited; wrong session name; requesting an unsupported output format.
Related errors
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/6bcbf15677799c92.
Report an issue: GitHub.