Claude provider: handle plain-string message content (current Claude Code logs collect zero records) - #2
Open
wrg32786 wants to merge 1 commit into
Open
Conversation
Current Claude Code writes message.content as a plain string for simple turns and as a list of blocks otherwise; some records also carry non-dict blocks and non-dict message fields. The collector assumed list-of-dicts everywhere, so the first string aborted the whole Claude walk with "'str' object has no attribute 'get'" and the report showed zero Claude usage. Guard all three sites: _extract_text accepts str content, the tool-name walk only iterates list content with dict blocks, and the usage pass only reads dict messages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NSjPuP4TH9zLbBXk4Z3FZf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Claude Code session logs write
message.contentas a plain string for simple turns and as a list of content blocks otherwise. Some records also carry non-dict blocks, and a few carry non-dictmessagefields.The Claude collector assumes list-of-dicts everywhere, so the first plain-string content aborts the entire walk with
'str' object has no attribute 'get'and the report shows zero Claude usage. On a machine with heavy current-version Claude Code use, the tool reports $0.00 and 0 calls across the board.This PR guards the three sites:
_extract_textreturns string content directly and skips non-dict blocks;usagefrom dict messages.Verified on real logs: before the patch, 0 records and an all-zero report with the warning above; after the patch, the same corpus collects tens of thousands of calls with per-project and per-day breakdowns populated. No behavior change for logs that already parse.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NSjPuP4TH9zLbBXk4Z3FZf