Textualize/textual · error · DecodeError

More data expected

Error message

More data expected

What it means

While decoding, get_byte() detects that the position pointer has reached the end of the buffer but the encoded structure says more bytes should follow, and raises DecodeError('More data expected'). It indicates a truncated or corrupt payload, not a caller type mistake.

Source

Thrown at src/textual/_binary_encode.py:197

        Decoded data.
    """
    if not isinstance(encoded, bytes):
        raise TypeError("must be bytes")
    max_position = len(encoded)
    position = 0

    def get_byte() -> bytes:
        """Get an encoded byte and advance position.

        Raises:
            DecodeError: If the end of the data was reached

        Returns:
            A bytes object with a single byte.
        """
        nonlocal position
        if position >= max_position:
            raise DecodeError("More data expected")
        character = encoded[position : position + 1]
        position += 1
        return character

    def peek_byte() -> bytes:
        """Get the byte at the current position, but don't advance position.

        Returns:
            A bytes object with a single byte.
        """
        return encoded[position : position + 1]

    def get_bytes(size: int) -> bytes:
        """Get a number of bytes of encode data.

        Args:
            size: Number of bytes to retrieve.

View on GitHub (pinned to 06dbeef4bb)

Solutions

  1. Ensure the full message is received before decoding (read exact declared length from the socket)
  2. Re-request or regenerate the payload instead of decoding partial data
  3. If relaying devtools traffic, preserve frame boundaries and byte-for-byte content
  4. Add a length prefix or use the protocol's framing when transporting encoded blobs
Defensive patterns

Strategy: try-catch

Try / catch

from textual._binary_encode import DecodeError
try:
    value = load(payload)
except DecodeError:
    value = None  # discard truncated frame, request resend

Prevention

When it happens

Trigger: Passing truncated bytes to load(); a payload that was cut off mid-transmission over the devtools socket; hand-crafted byte sequences that don't match the encoding grammar.

Common situations: Partial reads from a socket/stream (reading fewer bytes than the message length), bugs in a proxy or relay that split/concatenate frames incorrectly, or corrupted cached binary data.

Related errors


AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27). Data as JSON: /api/errors/d11508f10f5be205. Report an issue: GitHub.