Skip to content

Release 0.2.2: a wrong content guess is UnknownFormat, not a misleading parse error - #50

Merged
copyleftdev merged 1 commit into
mainfrom
fix/weak-sniff-unknown-0.2.2
May 31, 2026
Merged

copyleftdev merged 1 commit into
mainfrom
fix/weak-sniff-unknown-0.2.2

Conversation

@copyleftdev

@copyleftdev copyleftdev commented May 31, 2026 •

Copy link
Copy Markdown
Owner

Found while running anomalyx against real datasets (an Apache error_log): a
plain-text line that merely starts with [ got claimed by the JSON parser's
cheap leading-[/{ sniff, and when the JSON parse then failed the user saw
failed to parse json input — pointing them at the wrong problem.

Fix

ParserRegistry::normalize now tracks how the parser was resolved:

  • A parse failure under a weak (TEXT/FALLBACK) content sniff → the guess
    was wrong → AxError::UnknownFormat ("I don't recognize this").
  • A format identified confidently — by file extension, or a MAGIC/STRONG
    signature — still surfaces a genuine malformed-file parse error unchanged
    (a broken .json or a truncated Parquet still says so).

resolve() is unchanged; resolve_detail() is the new internal helper.

Tests pin all three paths (weak-sniff→UnknownFormat, extension→Parse,
STRONG-sniff→Parse) and the < STRONG boundary. Mutation gate on the changed
file: 0 surviving mutants. Bumps 0.2.1 → 0.2.2.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed JSON content sniffing to correctly report unknown format instead of parse errors when format detection confidence is low.
  • Chores

    • Version bumped to 0.2.2.

…ng parse error

Found while running anomalyx against real datasets: feeding an Apache error_log
(lines start with '[') produced 'failed to parse json input' — the JSON parser's
cheap leading-[/{ sniff claimed it, then the parse failed and surfaced JSON's
internal error, pointing the user at the wrong problem.

Fix: ParserRegistry::normalize now tracks how the parser was resolved. A parse
failure under a weak (TEXT/FALLBACK) content sniff means the guess was wrong, so
it reports AxError::UnknownFormat — 'I don't recognize this' rather than 'your
JSON is broken'. A format identified confidently (by file extension, or a
MAGIC/STRONG signature) still surfaces a genuine malformed-file parse error
unchanged. resolve() is unchanged; resolve_detail() is the new internal helper.

Tests pin all three paths (weak-sniff fail -> UnknownFormat; extension fail ->
Parse; STRONG-sniff fail -> Parse) and the < STRONG boundary. Bumps 0.2.1 ->
0.2.2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 02eee817-8276-4096-823a-c0044b4cd34f

📥 Commits

Reviewing files that changed from the base of the PR and between d4c8ce8 and 005a28d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • CHANGELOG.md
  • Cargo.toml
  • crates/ax-normalize/src/parser.rs

📝 Walkthrough

Walkthrough

This PR refactors the parser registry to classify JSON content sniffing errors more accurately. When content detection yields a weak confidence score and parsing fails, the error now reports UnknownFormat rather than a misleading format-specific parse error. Strong signatures and explicit extensions preserve original parse errors. Version bumped to 0.2.2 with updated documentation.

Changes

JSON Parser Error Classification

Layer / File(s) Summary
Weak Sniff Error Classification
crates/ax-normalize/src/parser.rs
New Resolution enum tracks parser selection method (extension vs sniff). resolve_detail helper returns parser paired with selection confidence. normalize refactored to map weak-sniff parse failures to UnknownFormat, while extension and strong-sniff parse failures surface original errors. Tests validate weak sniff, strong sniff, and extension-based behaviors.
Version 0.2.2 Release Documentation
CHANGELOG.md, Cargo.toml
Changelog documents weak sniff error classification fix dated 2026-05-31. Workspace version and internal dependencies (ax-core, ax-normalize, ax-detect) updated from 0.2.1 to 0.2.2. Release comparison links updated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A parser's whisper, once confused with shout,
Now knows when sniffs are weak—no doubt!
Strong JSON still screams its parsing woe,
While weak guesses gracefully let unknowns go. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing how weak content sniffs handle parsing failures by reporting UnknownFormat instead of misleading parse errors, which aligns perfectly with the core change across all modified files (version bump, changelog, and parser logic refactor).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/weak-sniff-unknown-0.2.2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@copyleftdev
copyleftdev merged commit 70bab60 into main May 31, 2026
1 of 2 checks passed
@copyleftdev
copyleftdev deleted the fix/weak-sniff-unknown-0.2.2 branch May 31, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant