[Bug]: JSONLinesFileReader drops rows containing U+2028, U+2029 or U+0085 (uses str.splitlines)
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
Direzione di ricerca
Il bug è in read_file in packages/graphrag-input/graphrag_input/jsonl.py, dove text.splitlines() viene usato per dividere i record. Sostituisci questa suddivisione con una divisione solo su "\n e rimuovi un "\r" finale per riga, mantenendo la numerazione delle righe e il comportamento degli avvisi di salto esistenti. Aggiungi un test con U+2028, U+2029 e U+0085 all'interno di un valore stringa, poi esegui i test esistenti del lettore JSONL. Completato quando queste righe vengono lette integre e i file CRLF continuano a essere analizzati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 36.6k
- Fork
- 3.9k
- Merge medio
- 4g 11h
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/graphrag
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
microsoft/graphrag#2626 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: response_format_json_object=True is silently dropped, so JSON mode never reaches the modelApertabug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
microsoft/graphrag#2625 · 1 commento ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: JsonCache.get() crashes with unhandled AttributeError on non-dict or invalid envelope JSON payloadsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
microsoft/graphrag#2614 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: TokenChunker never terminates when chunking overlap >= size (no validation of size/overlap)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/graphrag#2593 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di microsoft/graphrag
Issue simili
-
Input: placeholder drawn in the text colour when the empty Input is focused but not yet editedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pierreaubert/gpui-toolkit#114 ·
I maintainer di solito rispondono entro 1 giorno
-
intake mcp-intake needs-human-review priority:high type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
Ikalus1988/MisakaNet#4903 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
FinanceFlash/unvibecode#819 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno