{"record":{"id":"ab820764e6fcf38a","repo":"prestodb/presto","slug":"arrayoffset-is-negative","errorCode":null,"errorMessage":"arrayOffset is negative","messagePattern":"arrayOffset is negative","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java","lineNumber":78,"sourceCode":"                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\");\n        }\n\n        if (positionCount < 0) {\n            throw new IllegalArgumentException(\"positionCount is negative\");\n        }\n\n        if (valueIsNull != null && valueIsNull.length - arrayOffset < positionCount) {\n            throw new IllegalArgumentException(\"isNull length is less than positionCount\");\n        }\n\n        requireNonNull(offsets, \"offsets is null\");\n        if (offsets.length - arrayOffset < positionCount + 1) {\n            throw new IllegalArgumentException(\"offsets length is less than positionCount\");\n        }\n\n        requireNonNull(values, \"values is null\");\n    }\n","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java#L60-L96","documentation":"validateConstructorArguments rejects a negative arrayOffset when building an ArrayBlock. This fires when the starting offset into the offsets array is invalid — corrupt or miscomputed block construction parameters.","triggerScenarios":"Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlock.java:78 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the caller producing a negative arrayOffset (view/slice arithmetic bug)","Pass a non-negative base offset when constructing the block"],"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"}