-
fix: ndjson file type detection (#4349)
发布于
2026-05-05 13:46:11 +00:00 This PR fixes a bug where njson detection misclassifies multiline single
json files as ndjson.
Note
Medium Risk
Changes JSON/NDJSON detection heuristics anddetect_filetype
routing, which can affect which partitioner is invoked for JSON-like
inputs. The logic is more strict and covered by new edge-case tests, but
misclassification could still impact downstream parsing behavior.Overview
Fixes NDJSON file-type detection so multi-line single JSON objects
(including.jsonand.ipynbnotebook payloads) are no longer
misrouted topartition_ndjsonand crashing.Updates
is_ndjson_processableto require the first line to
independently parse as a JSON object (with special handling for
potentially truncated long single-line records), adds a bounded read
helper (json_disambiguation_text) for disambiguation beyond the 4KB
text_head, and changes JSON/NDJSON disambiguation to default to
FileType.JSONwhen NDJSON criteria aren’t met.Adds a focused test suite for these NDJSON edge cases, bumps version
to0.22.27, updates the changelog, and makes CI apt installs more
resilient by wrapping them in a retry helper.Reviewed by Cursor Bugbot for commit
e82dbd7d017e2a1f1d5406ad8ca887109b3c5553. Bugbot is set up for automated
code reviews on this repo. Configure
here.下载附件