{"record":{"id":"ee0094e98cb63709","repo":"Hmbown/CodeWhale","slug":"antigravity-cloud-code-sse-is-not-json-err","errorCode":null,"errorMessage":"Antigravity cloud-code SSE is not JSON: {err}","messagePattern":"Antigravity cloud-code SSE is not JSON: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/client/cloud_code.rs","lineNumber":218,"sourceCode":"                        Ok(None) => break,\n                        Err(err) => {\n                            yield Err(anyhow::anyhow!(\"{err}\"));\n                            return;\n                        }\n                    };\n                    if line.is_empty() || line.starts_with(':') {\n                        continue;\n                    }\n                    let Some(data) = super::extract_sse_data_value(&line) else {\n                        continue;\n                    };\n                    if data == \"[DONE]\" {\n                        break;\n                    }\n                    let value: Value = match serde_json::from_str(data) {\n                        Ok(value) => value,\n                        Err(err) => {\n                            yield Err(anyhow::anyhow!(\n                                \"Antigravity cloud-code SSE is not JSON: {err}\"\n                            ));\n                            return;\n                        }\n                    };\n                    if let Some(error) = value.get(\"error\") {\n                        yield Ok(StreamEvent::Error {\n                            error: error.clone(),\n                        });\n                        return;\n                    }\n                    let Some(text) = extract_cloud_code_text(&value) else {\n                        if value.get(\"response\").is_some() || value.get(\"candidates\").is_some() {\n                            continue;\n                        }\n                        yield Err(anyhow::anyhow!(\n                            \"Antigravity cloud-code SSE shape is unproven; failing closed\"\n                        ));","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/client/cloud_code.rs#L200-L236","documentation":"Each cloud-code SSE data frame that is not the [DONE] sentinel is parsed with serde_json::from_str. If the frame is not valid JSON, the adapter yields 'Antigravity cloud-code SSE is not JSON' with the serde error and terminates the stream - it does not skip the frame or attempt recovery.","triggerScenarios":"The gateway answers the SSE route with an HTML login/error page or plain-text message; a proxy error or block page injected mid-stream; a data frame containing non-JSON text (banner, logging preamble); partial frame corruption.","commonSituations":"Expired or missing Antigravity credentials returning an HTML auth redirect; a wrong base URL; corporate proxies injecting block pages; environment banners prepended to streams.","solutions":["Replay the same request with curl -N to see the actual frame content.","If it is an auth or HTML page, fix credentials or the endpoint URL before retrying.","Remove proxy injections (block pages, banners) on the cloud-code route.","If frames are genuinely JSON but interleaved with text, report upstream - the adapter fails closed on the first non-JSON frame."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust: probe that cloud-code data frames are JSON before wiring the consumer\nlet first = first_data_frame(&mut resp).await?; // \"data: {...}\"\nlet payload = extract_sse_data_value(&first).context(\"no data frame\")?;\nserde_json::from_str::<serde_json::Value>(payload)\n    .context(\"cloud-code route returned non-JSON (auth page?)\")?;\n","typeGuard":null,"tryCatchPattern":"// deterministic - fix credentials/endpoint instead of retrying\nErr(err) if err.to_string().contains(\"SSE is not JSON\") => {\n    return Err(err.context(\"verify cloud-code credentials and base URL\"));\n}\n","preventionTips":["Confirm cloud-code credentials are valid before long sessions - HTML auth pages are the usual non-JSON payload.","Keep proxy block pages and banners off the SSE route.","Pin the base URL to the documented cloud-code endpoint."],"tags":["sse","json","cloud-code","antigravity","gateway","auth"],"backgroundTag":"invalid-json-response","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}