fix(provider): handle UTF-8 BOM in JSON and CSV parsing#24
Conversation
|
CodeAnt AI is reviewing your PR. |
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
🤖 Augment PR SummarySummary: Ensures signature parsing correctly handles UTF-8 BOM-prefixed inputs. 🤖 Was this summary useful? React with 👍 or 👎 |
Sequence DiagramThis PR updates the signature loading flow to strip a UTF-8 BOM before format detection and parsing so that JSON and CSV inputs with a BOM are parsed correctly. sequenceDiagram
participant Caller
participant Provider
Caller->>Provider: load signatures from input
Provider->>Provider: Read file or stdin into string
Provider->>Provider: Strip UTF-8 BOM prefix if present
Provider->>Provider: Detect format as JSON or CSV
alt JSON format
Provider->>Provider: Parse JSON and normalize inputs
else CSV format
Provider->>Provider: Parse CSV and normalize inputs
end
Provider-->>Caller: Return parsed signatures list
Generated by CodeAnt AI |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Trivial fix to handle UTF-8 BOM in input parsing with regression tests.
Architecture diagram
sequenceDiagram
participant Client
participant P as Provider (parse_signatures)
participant D as detect_format()
participant Parser as JSON/CSV Parsers
Note over Client,Parser: Signature Ingestion Flow
Client->>P: parse_signatures(raw_content)
P->>P: NEW: strip_prefix(BOM)
Note right of P: Removes \u{FEFF} if present at start
P->>D: detect_format(stripped_content)
D-->>P: returns Format (Json | Csv)
alt Format::Json
P->>Parser: CHANGED: parse_json(stripped_content)
Parser-->>P: Vec<Signature>
else Format::Csv
P->>Parser: CHANGED: parse_csv(stripped_content)
Parser-->>P: Vec<Signature>
end
alt Success
P-->>Client: Ok(signatures)
else Parse Error (e.g. Malformed)
P-->>Client: Err(Error)
end
Nitpicks 🔍
|
|
CodeAnt AI finished reviewing your PR. |
Summary
I hit this while validating fixture ingestion from exported files.
detect_formatalready tolerated UTF-8 BOM, but actual parsing still used raw content, so BOM-prefixed input could be detected correctly and then fail inserde_jsonor CSV deserialization.Changes
parse_signaturesbefore dispatching to JSON/CSV parsersdetect_formattests for BOM-prefixed JSON and CSV inputTesting
cargo test --all-featurescargo clippy --all-features -- -D warningscargo build --releaseRelated Issues
Closes #25