Repository navigation
🧹 [code health] fix broad except in analyze-token-usage.py - #6
Conversation
…-usage.py Replaced the broad `except Exception:` clause in `tests/claude-code/analyze-token-usage.py` with specific exceptions: `json.JSONDecodeError`, `KeyError`, `AttributeError`, and `TypeError`. This prevents the script from silently ignoring unexpected errors while still safely skipping malformed log entries. Co-authored-by: pakorn269 <[email protected]>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR improves the robustness of the Claude Code session transcript token analyzer by narrowing an overly broad exception handler so unexpected failures surface while still tolerating malformed or structurally unexpected JSONL lines.
Changes:
- Replaced
except Exception:with a targeted set of data/parsing-related exceptions during per-line transcript parsing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replaced a broad
except Exception:clause with specific exceptions (json.JSONDecodeError,KeyError,AttributeError,TypeError) intests/claude-code/analyze-token-usage.py. This improves maintainability and debuggability by allowing unexpected errors to surface while still handling anticipated data-related issues when parsing session transcripts. Verified the change with sample valid and malformed data.PR created automatically by Jules for task 16657757307016695504 started by @pakorn269