{"record":{"id":"0d12f88e02b433f4","repo":"apache/flink","slug":"could-not-skip-numbytes-bytes-0d12f8","errorCode":null,"errorMessage":"Could not skip {numBytes} bytes.","messagePattern":"Could not skip (.+?) bytes\\.","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/memory/DataInputViewStreamWrapper.java","lineNumber":39,"sourceCode":"import org.apache.flink.annotation.PublicEvolving;\n\nimport java.io.DataInputStream;\nimport java.io.EOFException;\nimport java.io.IOException;\nimport java.io.InputStream;\n\n/** Utility class that turns an {@link InputStream} into a {@link DataInputView}. */\n@PublicEvolving\npublic class DataInputViewStreamWrapper extends DataInputStream implements DataInputView {\n\n    public DataInputViewStreamWrapper(InputStream in) {\n        super(in);\n    }\n\n    @Override\n    public void skipBytesToRead(int numBytes) throws IOException {\n        if (skipBytes(numBytes) != numBytes) {\n            throw new EOFException(\"Could not skip \" + numBytes + \" bytes.\");\n        }\n    }\n}\n","sourceCodeStart":21,"sourceCodeEnd":43,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/memory/DataInputViewStreamWrapper.java#L21-L43","documentation":"Thrown by DataInputViewStreamWrapper.skipBytesToRead(int) when the underlying InputStream's skipBytes returned fewer bytes than requested, i.e. the stream reached EOF before numBytes could be skipped. This wrapper adapts a blocking InputStream to the DataInputView contract and treats a short skip as a hard EOF.","triggerScenarios":"Calling skipBytesToRead(n) on a DataInputViewStreamWrapper whose backing InputStream has fewer than n bytes remaining (or returns -1).","commonSituations":"Truncated network stream or file; closed/drained input stream; a record header declaring more skip bytes than the payload contains; reading past the end of a fixed-size message.","solutions":["Confirm the stream contains at least numBytes before skipping (e.g. via available() or a known message length).","Ensure the source stream is fully buffered/complete before deserialization.","Handle EOFException to detect truncation at the framing layer."],"exampleFix":"// before\nview.skipBytesToRead(fieldSize);\n\n// after\ntry {\n    view.skipBytesToRead(fieldSize);\n} catch (EOFException e) {\n    throw new IOException(\"Stream truncated while skipping field of \" + fieldSize + \" bytes\", e);\n}","handlingStrategy":"try-catch","validationCode":"// Best-effort: check stream availability before skipping\nif (in.available() > 0 && in.available() < numBytes) {\n    throw new EOFException(\"Stream has only \" + in.available() + \" bytes, need \" + numBytes);\n}","typeGuard":null,"tryCatchPattern":"try {\n    view.skipBytesToRead(numBytes);\n} catch (EOFException e) {\n    throw new IOException(\"Input stream truncated before \" + numBytes + \" bytes could be skipped\", e);\n}","preventionTips":["Ensure the source stream is complete before wrapping it for deserialization.","Frame messages with an explicit length and validate it against the stream before skipping.","Handle EOFException at the framing layer to detect truncation cleanly."],"tags":["serialization","stream","eof","deserialization"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}