Chunked text processing silently drops the end of long texts
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start with ChunkService::chunkSplitPrompt() and trace how its paragraph, sentence, and word split patterns handle text that lacks a trailing separator. The issue reports that the author is preparing a fix with unit tests for all three split levels and fall-through behavior. Done means concatenating the chunks reproduces the full input, including its final text.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Which version of integration_openai are you using?
main (6.0.0-dev), the bug exists in released versions as well
Which version of Nextcloud are you using?
stable35
Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.
not relevant
Describe the Bug
When a text is long enough to be split into chunks, the end of the text can be silently dropped before anything is sent to the AI service. The truncated output looks successful, part of the source text is just missing.
ChunkService::chunkSplitPrompt() splits by paragraph, then by sentence, then by word, using patterns anchored on a trailing separator (\n, [!.?\n], \W). Each level returns as soon as it produces at least one chunk. Whatever part of the text does not end with that level's separator is never matched, and it is not passed down to the finer levels either, so it is lost:
input: "aaaa bbbb cccc\ndddd eeee ffff\ngggg hhhh" (maxChars = 20)
chunks: "aaaa bbbb cccc\n" + "dddd eeee ffff\n"
-> "gggg hhhh" never appears in any chunk
The same loss happens one level down when the text does not end with sentence punctuation, and one level further down for the last word of a text ending with a word character.
The affected call sites include translation, summary, proofread, context write, topics, reformat, improve, reformulate and change tone. Translation is the easiest to hit in practice: with the default configuration it chunks at min(chunk_size, max_tokens) * 3 ≈ 3000 characters, so translating a few paragraphs is enough. A translated document can simply miss its ending.
Expected Behavior
Every chunk contains a part of the input and concatenating the chunks gives back the full input, whatever characters the text ends with. The split should fall through to the finer level for the unmatched tail instead of dropping it.
To Reproduce
Reproduced end to end on a live Nextcloud 35.0.3 instance with the translation task, using a local mock provider that echoes back exactly what it receives. A 3491-character input whose final line has no trailing newline:
- input sent to translation: 3491 characters
- concatenated text actually received by the provider: 3441 characters
- the entire final line (50 characters) never reached the provider
A control input identical but ending with a newline went through without any loss (3492 characters in, 3492 out), confirming that the loss depends on the trailing separator.
The split logic itself is deterministic and runs entirely before the API call, so it can also be demonstrated without a provider:
$maxChars = 20;
$prompt = "aaaa bbbb cccc\ndddd eeee ffff\ngggg hhhh";
preg_match_all("/.{1,{$maxChars}}\n/su", $prompt, $chunks);
// implode('', $chunks[0]) is 30 chars long, the input is 39:
// the tail after the last newline is missing from the chunks
I am preparing a fix with unit tests covering the three split levels and the fall-through behaviour.
Assisted by Devin:SWE-2.1
- Lenguaje dominante
- PHP
- Estrellas
- 78
- Forks
- 42
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin 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 nextcloud/integration_openai
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
nextcloud/integration_openai#480 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
nextcloud/integration_openai#477 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
nextcloud/integration_openai#471 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Vllm rejecting requests that have empty tools listPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
nextcloud/integration_openai#448 · 3 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Solve 2 transcription problems: Video input and big inputPosiblemente ocupada @danafon la tomó hace 1 día. Abiertobug enhancement priority: high
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
nextcloud/integration_openai#472 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud/integration_openai
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
Automattic/static-site-importer#3462 ·
Los mantenedores suelen responder en 1 día
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.phpAbiertoenhancement feature: settings good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
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 76/100
roundcube/roundcubemail#10468 ·
Los mantenedores suelen responder en 1 día
-
a11y
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
omeka/plugin-Contribution#84 ·