{"record":{"id":"40003fcc7d454601","repo":"xai-org/grok-build","slug":"resize-failed-body","errorCode":null,"errorMessage":"resize failed: {body}","messagePattern":"resize failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/ptyctl-cli/src/commands/client.rs","lineNumber":145,"sourceCode":"/// Resize terminal.\npub async fn resize(url: &str, size: &str) -> Result<()> {\n    let (cols, rows) = size\n        .split_once('x')\n        .ok_or_else(|| anyhow::anyhow!(\"invalid size format, expected COLSxROWS (e.g. 120x40)\"))?;\n    let cols: u16 = cols.parse().context(\"invalid cols\")?;\n    let rows: u16 = rows.parse().context(\"invalid rows\")?;\n\n    let client = client_for(url)?;\n    let resp = client\n        .post(format!(\"{url}/control/resize\"))\n        .json(&serde_json::json!({\"cols\": cols, \"rows\": rows}))\n        .send()\n        .await\n        .context(\"failed to resize\")?;\n\n    if !resp.status().is_success() {\n        let body = resp.text().await.unwrap_or_default();\n        anyhow::bail!(\"resize failed: {body}\");\n    }\n    println!(\"Resized to {cols}x{rows}\");\n    Ok(())\n}\n\n/// Long-poll the wait endpoint; prints the outcome JSON and returns whether it matched.\npub async fn wait(\n    url: &str,\n    text: Option<&str>,\n    regex: Option<&str>,\n    gone: Option<&str>,\n    stable_ms: Option<u64>,\n    timeout_secs: u64,\n) -> Result<bool> {\n    // The HTTP timeout outlasts the wait so the server, not the client, decides the outcome.\n    #[allow(clippy::disallowed_methods)]\n    // scheme-aware builder above; loopback skips roots by construction\n    let client = builder_for(url)","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/ptyctl-cli/src/commands/client.rs#L127-L163","documentation":"resize() sends a cols/rows resize request to the session server. A non-2xx response is turned into this error including the server's body text.","triggerScenarios":"POST to the resize endpoint with a non-2xx reply — session gone, port stale, or resize rejected (e.g. invalid dimensions).","commonSituations":"Automated TUI test harnesses resizing sessions that have exited; stale registry entries pointing at dead ports; zero/negative dimensions.","solutions":["Check the error body for the server's reason","Validate cols/rows are positive before calling","Verify the session is alive; refresh stale registry entries","Restart the session and retry"],"exampleFix":"// before\nclient.resize(session, 0, 0).await?;\n// after\nif cols > 0 && rows > 0 {\n    client.resize(session, cols, rows).await?;\n}","handlingStrategy":"validation","validationCode":"fn valid_size(cols: u16, rows: u16) -> bool {\n    cols > 0 && rows > 0 && cols <= 1000 && rows <= 1000\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp dimensions to sane positive bounds before resizing","Confirm the session is alive before issuing resize","Refresh stale registry entries that point at dead ports"],"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"}