unstructured
8daa154a - fix: ndjson file type detection (#4349)

Commit
111 days ago
fix: ndjson file type detection (#4349) This PR fixes a bug where njson detection misclassifies multiline single json files as ndjson. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes JSON/NDJSON detection heuristics and `detect_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 `.json` and `.ipynb` notebook payloads) are no longer misrouted to `partition_ndjson` and crashing. > > Updates `is_ndjson_processable` to 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.JSON` when NDJSON criteria aren’t met. > > Adds a focused test suite for these NDJSON edge cases, bumps version to `0.22.27`, updates the changelog, and makes CI apt installs more resilient by wrapping them in a retry helper. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e82dbd7d017e2a1f1d5406ad8ca887109b3c5553. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Author
Parents
Loading