{"record":{"id":"a22758ed9ea8c2ce","repo":"apache/flink","slug":"could-not-skip-numbytes-bytes","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/DataInputDeserializer.java","lineNumber":377,"sourceCode":"\n    @Override\n    public int skipBytes(int n) {\n        if (this.position <= this.end - n) {\n            this.position += n;\n            return n;\n        } else {\n            n = this.end - this.position;\n            this.position = this.end;\n            return n;\n        }\n    }\n\n    @Override\n    public void skipBytesToRead(int numBytes) throws IOException {\n        int skippedBytes = skipBytes(numBytes);\n\n        if (skippedBytes < numBytes) {\n            throw new EOFException(\"Could not skip \" + numBytes + \" bytes.\");\n        }\n    }\n\n    @Override\n    public int read(@Nonnull byte[] b, int off, int len) throws IOException {\n\n        if (off < 0) {\n            throw new IndexOutOfBoundsException(\"Offset cannot be negative.\");\n        }\n\n        if (len < 0) {\n            throw new IndexOutOfBoundsException(\"Length cannot be negative.\");\n        }\n\n        if (b.length - off < len) {\n            throw new IndexOutOfBoundsException(\n                    \"Byte array does not provide enough space to store requested data\" + \".\");\n        }","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/memory/DataInputDeserializer.java#L359-L395","documentation":"Thrown by DataInputDeserializer.skipBytesToRead(int) when skipBytes(numBytes) returned fewer bytes than requested, i.e. the read position hit this.end before advancing numBytes. It is a hard EOF error (unlike skipBytes which silently clamps).","triggerScenarios":"Calling skipBytesToRead(n) when fewer than n bytes remain between position and end (available() < n).","commonSituations":"Deserializing a record whose declared size exceeds the remaining buffer; reading fields in the wrong order so position overshoots; a buffer truncated after the record header; padding bytes that aren't actually present.","solutions":["Check available() >= numBytes before skipBytesToRead.","Verify the read order matches the write order of the serializer.","Ensure the buffer contains the complete record before deserialization begins."],"exampleFix":"// before\ninput.skipBytesToRead(padding);\n\n// after\nif (input.available() >= padding) {\n    input.skipBytesToRead(padding);\n} else {\n    throw new EOFException(\"Record truncated; only \" + input.available() + \" bytes left\");\n}","handlingStrategy":"validation","validationCode":"if (input.available() < numBytes) {\n    throw new EOFException(\"Need \" + numBytes + \" bytes, only \" + input.available() + \" available\");\n}\ninput.skipBytesToRead(numBytes);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check available() >= numBytes before skipBytesToRead.","Match field read order to the writer's write order.","Confirm the buffer holds a complete record before deserializing."],"tags":["serialization","deserialization","eof","bounds-check"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}