fix(log-parser): validate configured delimiter - #4455
Conversation
Signed-off-by: Patrice Breton <pbreton@nvidia.com>
Summary by CodeRabbit
WalkthroughThe log parser validates delimiters through ChangesDelimiter validation
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/log-parser/src/main.rs`:
- Line 297: Update the record-processing path around delimiter_byte to use the
delimiter variable for both record detection and splitting instead of hard-coded
newline bytes, while preserving the existing seek calculation. Add a regression
case covering a non-newline delimiter such as "|" with input that lacks a
trailing newline, verifying the record is processed and its offset advances
correctly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: a373eed0-76e5-4279-a5d9-71198a213d7c
📒 Files selected for processing (2)
crates/log-parser/src/main.rscrates/log-parser/src/tests.rs
Signed-off-by: Patrice Breton <pbreton@nvidia.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/log-parser/src/tests.rs (1)
943-1015: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAssert the delimiter value and diagnostic.
inspect_delimitercurrently discards the parsedConfigurationand maps every error to(). Assert that omitted and"|"delimiters produceb'\n'andb'|', respectively, and that invalid delimiters return the delimiter-specific diagnostic.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/log-parser/src/tests.rs` around lines 943 - 1015, Update inspect_delimiter to retain the parsed Configuration and return or assert its delimiter value, verifying omitted input becomes b'\n' and "|" becomes b'|'. Preserve the existing test cases while matching invalid inputs against the delimiter-specific diagnostic instead of mapping all errors to ().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/log-parser/src/tests.rs`:
- Around line 943-1015: Update inspect_delimiter to retain the parsed
Configuration and return or assert its delimiter value, verifying omitted input
becomes b'\n' and "|" becomes b'|'. Preserve the existing test cases while
matching invalid inputs against the delimiter-specific diagnostic instead of
mapping all errors to ().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 2828b677-4d52-4586-b152-3b7afb5f1c78
📒 Files selected for processing (2)
crates/log-parser/src/main.rscrates/log-parser/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/log-parser/src/main.rs
Summary
Validate the log parser's configured delimiter before processing log files.
The delimiter must contain exactly one byte. Invalid configurations now return a descriptive error instead of panicking or silently using only the first byte.
Fixes #4401.
Root cause
process_log_file_eventsaccesseddelim.as_bytes()[0]without validating its length:Changes
Validation
cargo test -p carbide-log-parsercargo clippy -p carbide-log-parser --all-targets -- -D warningscargo fmt --all -- --checkgit diff --checkThe regression test was confirmed to fail before the fix and pass afterward.
Note
This is an attempt at fully automated issue resolution using Codex with Sol 5.6 Medium.