{"record":{"id":"fd05145c928ecb46","repo":"chenhg5/cc-connect","slug":"s-fd0514","errorCode":null,"errorMessage":"%s","messagePattern":"%s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/iflow/session.go","lineNumber":866,"sourceCode":"}\n\nfunc summarizeIFlowError(stderrText string, waitErr error) error {\n\tif stderrText != \"\" {\n\t\tfor _, line := range strings.Split(stderrText, \"\\n\") {\n\t\t\tline = strings.TrimSpace(line)\n\t\t\tif line == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif strings.HasPrefix(line, \"<Execution Info>\") || strings.HasPrefix(line, \"</Execution Info>\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif strings.HasPrefix(line, \"{\") || strings.HasPrefix(line, \"}\") || strings.HasPrefix(line, \"\\\"\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif utf8.RuneCountInString(line) > 300 {\n\t\t\t\tline = string([]rune(line)[:300]) + \"...\"\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"%s\", line)\n\t\t}\n\t}\n\tif waitErr != nil {\n\t\treturn fmt.Errorf(\"iflow process failed: %w\", waitErr)\n\t}\n\treturn fmt.Errorf(\"iflow API request failed\")\n}\n\nfunc (s *iflowSession) RespondPermission(_ string, _ core.PermissionResult) error {\n\treturn nil\n}\n\nfunc (s *iflowSession) Events() <-chan core.Event {\n\treturn s.events\n}\n\nfunc (s *iflowSession) CurrentSessionID() string {\n\tv, _ := s.sessionID.Load().(string)","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/iflow/session.go#L848-L884","documentation":"summarizeIFlowError extracts a human-readable failure reason from iflow CLI output: it skips JSON-looking lines, truncates to 300 runes, and wraps the first plain-text error line in an error via fmt.Errorf(\"%s\", line). The message is therefore raw CLI output, not a fixed string.","triggerScenarios":"readLoop calls summarizeIFlowError after the iflow process fails, and the CLI's stderr/stdout contained a plain-text (non-JSON) error line, e.g. quota exhausted, invalid API key, or model not available.","commonSituations":"Expired/invalid iflow credentials; upstream API quota or rate limit; requesting a model name the CLI doesn't support; network failure reported as a text line by the CLI.","solutions":["Read the wrapped line in the error message — it is the actual CLI diagnosis — and fix that condition","Re-authenticate or refresh iflow credentials if the line mentions auth/token","Check quota/billing if the line mentions rate or quota","Validate the requested model name against `iflow --help` / supported models"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := session.Send(ctx, msg, nil); err != nil {\n    msgText := err.Error() // the raw CLI line\n    if strings.Contains(msgText, \"auth\") || strings.Contains(msgText, \"token\") {\n        reauthenticateIFlow()\n    } else if strings.Contains(msgText, \"quota\") {\n        backoffAndRetry(msg)\n    }\n}","preventionTips":["Keep iflow credentials fresh; re-auth on auth-related lines","Monitor quota/rate limits and back off before hitting them","Validate model names against the installed CLI version"],"tags":["go","cli","error-parsing","iflow"],"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-14T00:17:10.932Z"}