{"record":{"id":"87e30d64881123e3","repo":"prestodb/presto","slug":"slice-is-null","errorCode":null,"errorMessage":"slice is null","messagePattern":"slice is null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/block/VariableWidthBlock.java","lineNumber":80,"sourceCode":"\n    public VariableWidthBlock(int positionCount, Slice slice, int[] offsets, Optional<boolean[]> valueIsNull)\n    {\n        this(0, positionCount, slice, offsets, valueIsNull.orElse(null));\n    }\n\n    VariableWidthBlock(int arrayOffset, int positionCount, Slice slice, int[] offsets, boolean[] valueIsNull)\n    {\n        if (arrayOffset < 0) {\n            throw new IllegalArgumentException(\"arrayOffset is negative\");\n        }\n        this.arrayOffset = arrayOffset;\n        if (positionCount < 0) {\n            throw new IllegalArgumentException(\"positionCount is negative\");\n        }\n        this.positionCount = positionCount;\n\n        if (slice == null) {\n            throw new IllegalArgumentException(\"slice is null\");\n        }\n        this.slice = slice;\n\n        if (offsets.length - arrayOffset < (positionCount + 1)) {\n            throw new IllegalArgumentException(\"offsets length is less than positionCount\");\n        }\n        this.offsets = offsets;\n\n        if (valueIsNull != null && valueIsNull.length - arrayOffset < positionCount) {\n            throw new IllegalArgumentException(\"valueIsNull length is less than positionCount\");\n        }\n        this.valueIsNull = valueIsNull;\n\n        sizeInBytes = offsets[arrayOffset + positionCount] - offsets[arrayOffset] + ((Integer.BYTES + Byte.BYTES) * (long) positionCount);\n        retainedSizeInBytes = INSTANCE_SIZE + slice.getRetainedSize() + sizeOf(valueIsNull) + sizeOf(offsets);\n    }\n\n    @Override","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/block/VariableWidthBlock.java#L62-L98","documentation":"VariableWidthBlock stores variable-length values in a Slice plus an offsets array; a null backing slice cannot hold any data, so the constructor throws IllegalArgumentException. The slice is required even for zero-position blocks.","triggerScenarios":"Passing a null Slice to a VariableWidthBlock constructor, e.g. when a deserializer gets an empty/uninitialized buffer and forwards null instead of Slices.EMPTY_SLICE.","commonSituations":"Deserialization paths where a missing column page yields null instead of an empty slice; tests constructing blocks by hand with null data.","solutions":["Pass Slices.EMPTY_SLICE (or an empty wrapped buffer) instead of null.","Fix upstream deserialization to never emit null slices for empty pages.","In test code, build blocks via the VariableWidthBlockBuilder rather than raw constructors."],"exampleFix":"// before\nnew VariableWidthBlock(0, 0, null, offsets, null); // throws\n// after\nnew VariableWidthBlock(0, 0, Slices.EMPTY_SLICE, offsets, null);","handlingStrategy":"validation","validationCode":"Slice data = (rawSlice != null) ? rawSlice : Slices.EMPTY_SLICE;","typeGuard":null,"tryCatchPattern":"try {\n    new VariableWidthBlock(0, positionCount, slice, offsets, valueIsNull);\n} catch (IllegalArgumentException e) {\n    // null slice: rebuild with empty slice\n}","preventionTips":["Default missing pages to Slices.EMPTY_SLICE, never null","Fix deserializers that emit null buffers for empty columns","Prefer VariableWidthBlockBuilder over raw constructors in tests"],"tags":["presto","block","illegal-argument","null-value"],"backgroundTag":"null-constructor-argument","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}