[Bug]: TokenChunker never terminates when chunking overlap >= size (no validation of size/overlap)
Los mantenedores suelen responder en 5 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza en TokenChunker.__init__ en graphrag_chunking/token_chunker.py y en el bucle de ventanas de split_text_on_tokens, donde el paso chunk_size - chunk_overlap puede ser cero o negativo. Revisa también los campos size y overlap en graphrag_chunking/chunking_config.py. Reproduce el problema con un envoltorio de decode que cuente las llamadas y se detenga tras 1000. Está terminado cuando el constructor lanza ValueError si size no es positivo o si overlap está fuera de 0 <= overlap < size, con pruebas unitarias para valores iguales, mayores, cero y negativos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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 chunking, 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
split_text_on_tokens advances the window with start_idx += chunk_size - chunk_overlap (token_chunker.py#L65). When overlap == size the step is 0, so cur_idx never reaches len(input_tokens) and the while loop keeps appending chunks to result without ever exiting. When overlap > size the step is negative, start_idx moves backwards, and the loop also never terminates. size <= 0 has the same problem.
ChunkingConfig.size and ChunkingConfig.overlap are bare int fields with no validators (chunking_config.py#L25-L32), and TokenChunker.__init__ does not check them either (token_chunker.py#L20-L29). A settings.yaml with, say, size: 100 and overlap: 100 therefore gives a chunking step that hangs with no error message. The config value is operator-controlled, so this is a usability/robustness problem, not a security one.
A negative overlap is also accepted and silently skips tokens between consecutive windows.
Steps to reproduce
from graphrag_chunking.token_chunker import TokenChunker
enc = lambda s: [ord(c) for c in s]
dec = lambda t: "".join(chr(x) for x in t)
TokenChunker(size=10, overlap=10, encode=enc, decode=dec).chunk("abcdefghijklmnopqrstuvwxyz") # never returns
The same happens with overlap=15 or size=0.
I did not let the real call run to exhaustion. Instead I ran split_text_on_tokens with a decode wrapper that raises after 1000 calls: for both overlap=10 and overlap=15 (size 10) the cap was hit, i.e. the loop kept calling decode and appending chunks well past the 3 windows that 26 characters need. In the real loop result grows without bound.
Expected Behavior
A clear ValueError at config load / chunker construction when the values are invalid: require size > 0 and 0 <= overlap < size.
GraphRAG Config Used
chunking:
type: tokens
size: 100
overlap: 100
Logs and screenshots
No output: the process does not return.
Additional Information
- GraphRAG Version: 3.3.0 (graphrag-chunking at 5faaaf4f)
- Operating System: macOS
- Python Version: 3.11
- Related Issues: #2589 (a different TokenChunker bug, about decoding at token boundaries, in the same function)
Suggested minimal fix: validate in ChunkingConfig (Field(gt=0) on size, Field(ge=0) on overlap, plus a validator enforcing overlap < size) and raise ValueError in TokenChunker.__init__ so direct library use is covered too, with unit tests for equal, greater, zero and negative values. Happy to open a PR if that approach is fine.
- Lenguaje dominante
- Python
- Estrellas
- 36.6k
- Forks
- 3.9k
- Merge medio
- 4 d 11 h
- PR fusionados (30 d)
- 1
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/graphrag
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
microsoft/graphrag#2626 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
[Bug]: response_format_json_object=True is silently dropped, so JSON mode never reaches the modelAbiertobug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoft/graphrag#2625 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
Los mantenedores suelen responder en 5 días
-
[Bug]: JsonCache.get() crashes with unhandled AttributeError on non-dict or invalid envelope JSON payloadsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/graphrag#2614 · 2 comentarios ·
Los mantenedores suelen responder en 5 días
-
[Bug]: JSONLinesFileReader drops rows containing U+2028, U+2029 or U+0085 (uses str.splitlines)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
microsoft/graphrag#2594 · 1 comentario ·
Los mantenedores suelen responder en 5 días
Todos los issues de microsoft/graphrag
Issues similares
-
Input: placeholder drawn in the text colour when the empty Input is focused but not yet editedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pierreaubert/gpui-toolkit#114 ·
Los mantenedores suelen responder en 1 día
-
intake mcp-intake needs-human-review priority:high type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Ikalus1988/MisakaNet#4903 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
FinanceFlash/unvibecode#819 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día