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
- Ensure the full message is received before decoding (read exact declared length from the socket)
- Re-request or regenerate the payload instead of decoding partial data
- If relaying devtools traffic, preserve frame boundaries and byte-for-byte content
- 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
- Frame messages with a length prefix and read exactly that many bytes
- Validate payload integrity (checksum) before decoding
- Never decode partially-read socket buffers
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
- Missing bytes in {bytes_data!r}
- Can't encode {datum!r}
- must be bytes
- Can't animate attribute {attribute!r} on {obj!r}; attribute
- Don't know how to animate {value!r}; Can only animate <int>,
AI-assisted analysis of Textualize/textual@06dbeef4bb (2026-08-27).
Data as JSON: /api/errors/d11508f10f5be205.
Report an issue: GitHub.