{"record":{"id":"d41bf9fa82ba454a","repo":"chenhg5/cc-connect","slug":"claudecode-claude-code-usage-produced-empty-outp","errorCode":null,"errorMessage":"claudecode: Claude Code /usage produced empty output","messagePattern":"claudecode: Claude Code /usage produced empty output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/claudecode/claude_usage.go","lineNumber":305,"sourceCode":"\t\t\t\tout = append(out, \"\")\n\t\t\t\tlastBlank = true\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tline = claudeUsageWhitespaceRe.ReplaceAllString(line, \" \")\n\t\tif claudeUsageRuleLineRe.MatchString(line) {\n\t\t\tcontinue\n\t\t}\n\t\tout = append(out, line)\n\t\tlastBlank = false\n\t}\n\treturn strings.TrimSpace(strings.Join(out, \"\\n\"))\n}\n\nfunc parseClaudeUsageReport(text string, now time.Time) (*core.UsageReport, error) {\n\ttext = normalizeClaudeUsageText(text)\n\tif text == \"\" {\n\t\treturn nil, fmt.Errorf(\"claudecode: Claude Code /usage produced empty output\")\n\t}\n\tif err := detectClaudeUsageOutputError(text, \"\"); err != nil {\n\t\treturn nil, err\n\t}\n\n\treport := &core.UsageReport{\n\t\tProvider: \"claudecode\",\n\t}\n\n\tlines := strings.Split(text, \"\\n\")\n\tsession, err := parseClaudeUsageWindow(lines, \"Current session\", claudeUsageSessionWindowSeconds, now)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tweek, err := parseClaudeUsageWindow(lines, \"Current week\", claudeUsageWeekWindowSeconds, now)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/agent/claudecode/claude_usage.go#L287-L323","documentation":"A sentinel parse guard in parseClaudeUsageReport: after normalization the captured /usage screen is empty (only whitespace/rules). It fires when the probe returned before any content rendered, so there is nothing to parse into a UsageReport.","triggerScenarios":"Thrown at agent/claudecode/claude_usage.go:305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry /usage — the screen capture likely raced ahead of rendering","Check the probe timeout and increase it if the CLI is slow","Upgrade Claude Code if /usage renders nothing on this version"],"exampleFix":null,"handlingStrategy":"retry","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-14T05:17:10.506Z"}