[Bug]: JSONLinesFileReader drops rows containing U+2028, U+2029 or U+0085 (uses str.splitlines)
メンテナーはふだん 5 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
バグは packages/graphrag-input/graphrag_input/jsonl.py の read_file にあり、レコードの分割に text.splitlines() が使われています。この分割を "\n のみでの分割に置き換え、各行末の "\r" を取り除いてください。既存の行番号付けとスキップ警告の動作は維持します。文字列値の中に U+2028、U+2029、U+0085 を含むテストを追加し、既存の JSONL リーダーのテストを実行してください。これらの行が壊れずに読み込まれ、CRLF ファイルも引き続き解析できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Do you need to file an issue?
- I have searched the existing issues and this bug is not already filed.
- My model is hosted on OpenAI or Azure. If not, please look at the "model providers" issue and don't file a new one here. (Not applicable: the bug is in the input reader, before any model call.)
- I believe this is a legitimate bug, not just a question. If this is a question, please use the Discussions area.
Describe the bug
JSONLinesFileReader.read_file splits the file with text.splitlines() (jsonl.py#L38). Python's str.splitlines() also breaks on U+2028 (LINE SEPARATOR), U+2029 (PARAGRAPH SEPARATOR) and U+0085 (NEXT LINE). JSON Lines uses only \n as the record separator, and those three characters are valid unescaped inside JSON strings. A valid row containing one of them is therefore cut into two fragments, neither of which parses. Each fragment is logged as Skipping malformed JSONL row in <path> at line N, so that row is dropped from the input (the rest of the file is still read), and the only trace is a warning.
(Side note: splitlines() also splits on \x0b, \x0c, \x1c, \x1d and \x1e. Those are control characters that must be escaped in JSON, so they cannot occur unescaped in a valid row and are not part of this bug.)
Steps to reproduce
File x.jsonl, where the first row contains a raw U+2028 between a and b (shown here as <LS>):
{"text":"a<LS>b"}
{"text":"c"}
docs = await JSONLinesFileReader(storage=storage).read_files()
print([d.text for d in docs]) # ['c'] (expected ['a
b', 'c'])
# log: Skipping malformed JSONL row in x.jsonl at line 1
# Skipping malformed JSONL row in x.jsonl at line 2
json.loads('{"text":"a
b"}') parses fine on its own. The same happens with U+2029 and U+0085.
Expected Behavior
Both rows are read. Split on "\n" only and strip a trailing "\r" for CRLF files.
GraphRAG Config Used
input:
type: jsonl
Logs and screenshots
Skipping malformed JSONL row in x.jsonl at line 1
Skipping malformed JSONL row in x.jsonl at line 2
Additional Information
- GraphRAG Version: 3.3.0 (graphrag-input at 5faaaf4f)
- Operating System: macOS
- Python Version: 3.11
- Related Issues: #2424 / PR #2434 (JSONL reader skipped the whole file on blank lines). That is a different bug in the same function; the
splitlines()loop appears to have come in with that fix.
Suggested fix: for line_number, line in enumerate(text.split("\n"), start=1): line = line.rstrip("\r"), plus a test with U+2028 and U+0085 inside a string value.
- 主要言語
- Python
- スター
- 36.6k
- フォーク
- 3.9k
- 平均マージ
- 4日 11時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/graphrag のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
microsoft/graphrag#2626 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
[Bug]: response_format_json_object=True is silently dropped, so JSON mode never reaches the modelオープンbug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/graphrag#2625 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
メンテナーはふだん 5 日以内に返信
-
[Bug]: JsonCache.get() crashes with unhandled AttributeError on non-dict or invalid envelope JSON payloads再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/graphrag#2614 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
-
[Bug]: TokenChunker never terminates when chunking overlap >= size (no validation of size/overlap)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/graphrag#2593 · コメント 2 件 ·
メンテナーはふだん 5 日以内に返信
microsoft/graphrag の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pierreaubert/gpui-toolkit#114 ·
メンテナーはふだん 1 日以内に返信
-
intake mcp-intake needs-human-review priority:high type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Ikalus1988/MisakaNet#4903 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
FinanceFlash/unvibecode#819 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信