{"record":{"id":"be2dbae1591cf90d","repo":"apache/flink","slug":"bytes-cannot-be-null","errorCode":null,"errorMessage":"bytes cannot be null.","messagePattern":"bytes cannot be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java","lineNumber":114,"sourceCode":"\n        do {\n            // Logical change 2 (from Kryo Input.require): \"capacity - remaining\" -> \"required -\n            // remaining\"\n            count = fill(buffer, remaining, required - remaining);\n            if (count == -1) {\n                throw new KryoBufferUnderflowException(\"Buffer underflow.\");\n            }\n            remaining += count;\n        } while (remaining < required);\n\n        limit = remaining;\n        return remaining;\n    }\n\n    @Override\n    public int read(byte[] bytes, int offset, int count) throws KryoException {\n        if (bytes == null) {\n            throw new IllegalArgumentException(\"bytes cannot be null.\");\n        }\n\n        try {\n            return inputStream.read(bytes, offset, count);\n        } catch (IOException ex) {\n            throw new KryoException(ex);\n        }\n    }\n\n    @Override\n    public void skip(int count) throws KryoException {\n        try {\n            inputStream.skip(count);\n        } catch (IOException ex) {\n            throw new KryoException(ex);\n        }\n    }\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/NoFetchingInput.java#L96-L132","documentation":"Plain IllegalArgumentException from NoFetchingInput.read(byte[], int, int) when the destination array is null. This is a programmer-contract violation inside a Kryo read path, not an environmental failure.","triggerScenarios":"A Kryo Serializer or Kryo internals calling input.read(bytes, offset, count) with a null byte array while deserializing through Flink's NoFetchingInput.","commonSituations":"Custom Kryo serializer passes an uninitialized buffer (e.g. lazy field not yet allocated) to read(); copy-pasted serializer code with a null target array on a conditional branch.","solutions":["Allocate the destination byte[] before calling read (size = the count you will read)","Add a null check/Objects.requireNonNull in the custom serializer for early failure"],"exampleFix":"// before\nbyte[] buf;\ninput.read(buf, 0, len);\n\n// after\nbyte[] buf = new byte[len];\ninput.read(buf, 0, len);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(bytes, \"bytes\");\ninput.read(bytes, offset, count);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allocate buffers before read calls","Enable IDE nullness annotations to catch uninitialized locals"],"tags":["kryo","serialization","null-argument","programmer-error"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}