apache/flink · error · KryoException

No more bytes left.

Error message

No more bytes left.

What it means

KryoException wrapping EOFException, thrown by NoFetchingInput.readBytes when the underlying stream returns -1 before 'count' bytes have been read. It signals a truncated payload: the reader expected more bytes than the stream contains.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java:151

    @Override
    public void readBytes(byte[] bytes, int offset, int count) throws KryoException {
        if (bytes == null) {
            throw new IllegalArgumentException("bytes cannot be null.");
        }

        if (count == 0) {
            return;
        }

        try {
            int bytesRead = 0;
            int c;

            while (true) {
                c = inputStream.read(bytes, offset + bytesRead, count - bytesRead);

                if (c == -1) {
                    throw new KryoException(new EOFException("No more bytes left."));
                }

                bytesRead += c;

                if (bytesRead == count) {
                    break;
                }
            }
        } catch (IOException ex) {
            throw new KryoException(ex);
        }
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Confirm serializer schema symmetry: the reader must read field lengths exactly as the writer wrote them
  2. Validate the stream/framing integrity before deserialization (lengths, checksums)
  3. If this occurs on state restore, test restore against the exact checkpoint that produced the data and check for partial uploads
Defensive patterns

Strategy: try-catch

Try / catch

try {
    input.readBytes(buf, 0, len);
} catch (KryoException e) {
    if (e.getCause() instanceof EOFException) {
        throw new IOException("Truncated payload: expected " + len + " bytes", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Bulk readBytes(bytes, offset, count) where the serialized data ends early - e.g. a byte[]/String field whose stored length exceeds the remaining stream, or a cut-off stream mid-field.

Common situations: Corrupted or truncated checkpoints/savepoints; a length field written incorrectly (stale length after a field was resized); deserializing with a mismatched schema that reads a longer array length than was written.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/a1586f2c764b570d. Report an issue: GitHub.