{"record":{"id":"0c02d6d996b29207","repo":"chenhg5/cc-connect","slug":"s-0c02d6","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/qoder/session.go","lineNumber":206,"sourceCode":"\t// from hanging forever on the events channel.\n\tif len(nonJSONLines) > 0 {\n\t\t// qodercli produced plain text instead of stream-json; forward it\n\t\t// as a result so the user at least sees the response.\n\t\tslog.Warn(\"qoderSession: no result event, falling back to plain-text output\", \"lines\", len(nonJSONLines))\n\t\ttext := strings.Join(nonJSONLines, \"\\n\")\n\t\tevt := core.Event{Type: core.EventResult, Content: text, SessionID: qs.CurrentSessionID(), Done: true}\n\t\tselect {\n\t\tcase qs.events <- evt:\n\t\tcase <-qs.ctx.Done():\n\t\t}\n\t} else if exitErr != nil {\n\t\t// Process failed with no usable output.\n\t\tstderrMsg := strings.TrimSpace(stderrBuf.String())\n\t\tif stderrMsg == \"\" {\n\t\t\tstderrMsg = exitErr.Error()\n\t\t}\n\t\tslog.Error(\"qoderSession: process failed with no result\", \"error\", exitErr, \"stderr\", truncStr(stderrMsg, 200))\n\t\tevt := core.Event{Type: core.EventError, Error: fmt.Errorf(\"%s\", stderrMsg)}\n\t\tselect {\n\t\tcase qs.events <- evt:\n\t\tcase <-qs.ctx.Done():\n\t\t}\n\t} else if scanErr != nil {\n\t\t// Scanner error with no output.\n\t\tevt := core.Event{Type: core.EventError, Error: fmt.Errorf(\"read stdout: %w\", scanErr)}\n\t\tselect {\n\t\tcase qs.events <- evt:\n\t\tcase <-qs.ctx.Done():\n\t\t}\n\t} else {\n\t\t// Process exited cleanly but produced nothing at all.\n\t\tslog.Warn(\"qoderSession: process exited with no output and no result event\")\n\t\tevt := core.Event{Type: core.EventResult, Content: \"\", SessionID: qs.CurrentSessionID(), Done: true}\n\t\tselect {\n\t\tcase qs.events <- evt:\n\t\tcase <-qs.ctx.Done():","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/qoder/session.go#L188-L224","documentation":"readLoop in agent/qoder/session.go emits a core.EventError containing the child process's stderr (or the exit error itself if stderr is empty) when the qoder process exits without producing any usable stream-json result. It is the adapter's way of propagating CLI-level failures (bad flags, auth errors, crashes) to the engine as an event rather than a Send return error.","triggerScenarios":"qoder process exits non-zero with no parsed output events: invalid CLI flags/version mismatch, expired or missing qoder auth, CLI crash, or exitErr non-nil with empty stdout stream and non-scanner cause.","commonSituations":"qoder CLI updated and stream-json flags changed; API key/login expired so the CLI prints an auth error to stderr; OOM-kill or signal terminating the process mid-turn; running an unsupported qoder version.","solutions":["Read the event's Error text — it is the trimmed stderr from the CLI — and fix the reported cause","Run the qoder command manually with the same args (-p ... -f stream-json -q -w workDir) to reproduce","Re-authenticate the qoder CLI (login/API key) if the stderr mentions auth","Pin or update the qoder CLI version if flags changed","Check exit status/OOM (dmesg) if stderr is empty and the message is just the exit error"],"exampleFix":"// diagnose\n//   event error: \"unknown flag: -f\"\n// fix: align CLI version with expected flags\nqoder -p \"hi\" -f stream-json -q -w .   # verify manually before blaming the adapter","handlingStrategy":"try-catch","validationCode":"// before sending, verify the CLI accepts the flags:\n// exec.Command(\"qodercli\", \"-f\", \"stream-json\", \"-q\").Run()","typeGuard":null,"tryCatchPattern":"for evt := range sess.Events() {\n    if evt.Type == core.EventError {\n        slog.Error(\"qoder CLI failed\", \"stderr\", evt.Error)\n        // notify user and optionally recreate the session\n    }\n}","preventionTips":["Pin a known-good qoder CLI version; test after upgrades","Keep qoder authentication valid (login/API key expiry)","Consume EventError events and surface stderr to users","Reproduce failures by running the CLI manually with identical flags"],"tags":["go","process","stderr","cli"],"backgroundTag":"upstream-api-error","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}