Skip to content

Result chunk assembly silently accepts incomplete or gapped streams #36

Description

@nficano

src/Client/ResultChunkAssembler.php:32 assembles whatever chunks are currently present for a result id after sorting by sequence number. It does not require that a terminal chunk with more === false has arrived, it does not validate that sequence numbers are contiguous from zero, and push() silently overwrites duplicate sequence numbers. A client can therefore get a truncated or corrupted assembled result without any exception when a chunk is missing, duplicated with different data, or assembled too early.

This is risky because the README describes result chunks as part of an ordered stream that should survive reconnects gap-free, and the helper is the public client-side abstraction intended to make that stream usable. The current integration coverage only exercises the happy path in tests/Integration/JobLifecycleTest.php:237.

Fix prompt: Make ResultChunkAssembler track completion and validate integrity before returning bytes. assemble() should fail if the result id is unknown, no terminal chunk has arrived, the sequence range is not contiguous from zero through the terminal sequence, or a duplicate sequence arrives with conflicting payload metadata. Add PHPUnit tests for early assembly, missing middle chunks, duplicate conflicting chunks, out-of-order delivery, and valid base64 chunks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:mediumMedium severity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions