fix(cli): parse JSONL log lines that omit or capitalize the level field - #3082
fix(cli): parse JSONL log lines that omit or capitalize the level field#3082phil-opp wants to merge 1 commit into
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
`parse_jsonl_line` claimed to default a missing level to stdout
(`.unwrap_or("stdout")`), but the preceding `v.get("level")?` returned
`None` and discarded the whole line whenever the `level` key was absent,
so the fallback was unreachable for the common "no level key" case.
Additionally, the inline level match was case-sensitive and duplicated
`parse_log_level_str` (the single source of truth for level names): an
external tool emitting a capitalized level like "INFO" was shown but
misclassified as stdout, breaking level filtering and coloring.
Look the level up with `parse_log_level_str` and default to stdout when
the key is missing, non-string, or unrecognized. A line without a level
is now kept (as stdout) instead of dropped, and a capitalized level is
classified correctly. Adds regression tests for a missing key, a
non-string value, a capitalized level, and an unknown level.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SD4dBVimzepwKSh2b9F8aG
1177200 to
2997711
Compare
|
🤖 Automated review by Claude — this is a fully automated review with no human in the loop. I reviewed this diff and found no issues. The fix correctly replaces Generated by Claude Code |
Issue
parse_jsonl_line(binaries/cli/src/output.rs) parses daemon/compact JSONL log lines and is documented to tolerate compact formats. It had two related problems in its level handling:?onv.get("level")returnsNone— dropping the entire line — whenever thelevelkey is absent. The.unwrap_or("stdout")fallback was therefore unreachable for the common "no level key" case, so any externally-produced JSONL line withts/msgbut nolevelwas silently discarded.parse_log_level_str(the single source of truth for level names, which lowercases first). An external tool emitting a capitalized level like"INFO"hit the_ => Stdoutarm — the line was shown but misclassified as stdout, breaking--log-levelfiltering and coloring.Fix
Look the level up through
parse_log_level_str, defaulting to stdout when the key is missing, non-string, or unrecognized:A line without a level is now kept (as stdout) instead of dropped, a capitalized level is classified correctly, and the duplicated match is removed.
Validation
"INFO"→ Info), and an unknown level.cargo test -p dora-cli --lib output::— 21 passed.cargo fmt --all -- --checkandcargo clippy -p dora-cli -- -D warningsclean.The capitalization fix and the
parse_log_level_strreuse were added after an automated/review+/simplifypass flagged the case-sensitive duplication.🤖 This is a machine-generated pull request opened by Claude Code as part of an automated code-review pass. Please review carefully before merging.
🤖 Generated with Claude Code