{"record":{"id":"81dfa6707bc1cbc3","repo":"prestodb/presto","slug":"a-null-array-must-have-zero-entries","errorCode":null,"errorMessage":"A null array must have zero entries","messagePattern":"A null array must have zero entries","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java","lineNumber":60,"sourceCode":"    private volatile long logicalSizeInBytes;\n\n    /**\n     * Create an array block directly from columnar nulls, values, and offsets into the values.\n     * A null array must have no entries.\n     */\n    public static Block fromElementBlock(int positionCount, Optional<boolean[]> valueIsNullOptional, int[] arrayOffset, Block values)\n    {\n        boolean[] valueIsNull = valueIsNullOptional.orElse(null);\n        validateConstructorArguments(0, positionCount, valueIsNull, arrayOffset, values);\n        // for performance reasons per element checks are only performed on the public construction\n        for (int i = 0; i < positionCount; i++) {\n            int offset = arrayOffset[i];\n            int length = arrayOffset[i + 1] - offset;\n            if (length < 0) {\n                throw new IllegalArgumentException(format(\"Offset is not monotonically ascending. offsets[%s]=%s, offsets[%s]=%s\", i, arrayOffset[i], i + 1, arrayOffset[i + 1]));\n            }\n            if (valueIsNull != null && valueIsNull[i] && length != 0) {\n                throw new IllegalArgumentException(\"A null array must have zero entries\");\n            }\n        }\n        return new ArrayBlock(0, positionCount, valueIsNull, arrayOffset, values);\n    }\n\n    /**\n     * Create an array block directly without per element validations.\n     */\n    static ArrayBlock createArrayBlockInternal(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)\n    {\n        validateConstructorArguments(arrayOffset, positionCount, valueIsNull, offsets, values);\n        return new ArrayBlock(arrayOffset, positionCount, valueIsNull, offsets, values);\n    }\n\n    private static void validateConstructorArguments(int arrayOffset, int positionCount, @Nullable boolean[] valueIsNull, int[] offsets, Block values)\n    {\n        if (arrayOffset < 0) {\n            throw new IllegalArgumentException(\"arrayOffset is negative\");","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java#L42-L78","documentation":"ArrayBlock.fromElementBlock validation: a position whose valueIsNull entry is true must encode an empty array (offsets equal), but the given offsets/values describe a non-empty null array — inconsistent block construction arguments.","triggerScenarios":"Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Emit equal start/end offsets for null array positions in the producer","Verify null handling in the block builder or deserializer that produced these arrays"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}