{"record":{"id":"9759c393a44b6209","repo":"chenhg5/cc-connect","slug":"read-stdout-w-9759c3","errorCode":null,"errorMessage":"read stdout: %w","messagePattern":"read stdout: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/gemini/session.go","lineNumber":256,"sourceCode":"\t\tline := scanner.Text()\n\t\tif line == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tslog.Debug(\"geminiSession: raw\", \"line\", truncate(line, 500))\n\n\t\tvar raw map[string]any\n\t\tif err := json.Unmarshal([]byte(line), &raw); err != nil {\n\t\t\tslog.Debug(\"geminiSession: non-JSON line\", \"line\", line)\n\t\t\tcontinue\n\t\t}\n\n\t\tgs.handleEvent(raw)\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\tslog.Error(\"geminiSession: scanner error\", \"error\", err)\n\t\tevt := core.Event{Type: core.EventError, Error: fmt.Errorf(\"read stdout: %w\", err)}\n\t\tselect {\n\t\tcase gs.events <- evt:\n\t\tcase <-gs.ctx.Done():\n\t\t\treturn\n\t\t}\n\t}\n}\n\n// Gemini CLI stream-json event types:\n//\n//\tinit       — session_id, model\n//\tmessage    — role (user/assistant), content, delta\n//\ttool_use   — tool_name, tool_id, parameters\n//\ttool_result — tool_id, status, output, error\n//\terror      — severity, message\n//\tresult     — status, stats (final event)\nfunc (gs *geminiSession) handleEvent(raw map[string]any) {\n\teventType, _ := raw[\"type\"].(string)","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/gemini/session.go#L238-L274","documentation":"Wraps a bufio.Scanner error after the gemini stdout read loop ends: reading the CLI's JSON stream failed mid-turn (broken pipe, process death, or a line exceeding the scanner buffer). The error is emitted as an EventError so the user sees the failed turn.","triggerScenarios":"Thrown at agent/gemini/session.go:256 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check whether the gemini process crashed (see stderr events nearby)","Retry the message — transient pipe breakage happens on busy systems","If lines are too long, report upstream; the scanner buffer may need raising"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}