{"record":{"id":"6bcbf15677799c92","repo":"xai-org/grok-build","slug":"screen-query-failed-body","errorCode":null,"errorMessage":"screen query failed: {body}","messagePattern":"screen query failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/ptyctl-cli/src/commands/client.rs","lineNumber":76,"sourceCode":"    if let Some(r) = rows {\n        req = req.query(&[(\"rows\", r)]);\n    }\n    if let Some(c) = cols {\n        req = req.query(&[(\"cols\", c)]);\n    }\n    if let Some(ch) = cursor {\n        req = req.query(&[(\"cursor\", &ch.to_string())]);\n    }\n    req = req.query(&[(\"format\", format)]);\n    if full {\n        req = req.query(&[(\"full\", \"true\")]);\n    }\n\n    let resp = req.send().await.context(\"failed to query screen\")?;\n\n    if !resp.status().is_success() {\n        let body = resp.text().await.unwrap_or_default();\n        anyhow::bail!(\"screen query failed: {body}\");\n    }\n\n    let body = resp.text().await?;\n\n    if format == \"html\" || format == \"styled\" {\n        println!(\"{body}\");\n    } else {\n        // Parse as JSON and print lines.\n        let output: serde_json::Value = serde_json::from_str(&body)?;\n        if let Some(lines) = output.get(\"lines\").and_then(|l| l.as_array()) {\n            for (i, line) in lines.iter().enumerate() {\n                let text = line.as_str().unwrap_or(\"\");\n                if line_numbers {\n                    println!(\"{:4} {text}\", i + 1);\n                } else {\n                    println!(\"{text}\");\n                }\n            }","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/ptyctl-cli/src/commands/client.rs#L58-L94","documentation":"screen() queries the terminal content of a session. Non-2xx HTTP responses are converted into this error carrying the server's response body.","triggerScenarios":"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).","commonSituations":"Polling a session in test scripts after it exited; wrong session name; requesting an unsupported output format.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let info = registry::lookup_session(name)?; // fails fast if session unknown","typeGuard":null,"tryCatchPattern":"match client.screen(target, format).await {\n    Ok(out) => println!(\"{out}\"),\n    Err(e) if e.to_string().contains(\"screen query failed:\") => {\n        eprintln!(\"query rejected: {e}\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["http","network","cli"],"backgroundTag":"http-non-2xx-response","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}