prestodb/presto · error · IllegalArgumentException

position is not valid

Error message

position is not valid

What it means

checkReadablePosition is the bounds guard shared by all AbstractArrayBlock accessors: it fires when a caller indexes an array block with a position < 0 or >= positionCount — an out-of-range block access, normally an internal engine bug.

Source

Thrown at presto-common/src/main/java/com/facebook/presto/common/block/AbstractArrayBlock.java:303

    @Override
    public boolean mayHaveNull()
    {
        return getValueIsNull() != null;
    }

    public <T> T apply(ArrayBlockFunction<T> function, int position)
    {
        checkReadablePosition(position);

        int startValueOffset = getOffset(position);
        int endValueOffset = getOffset(position + 1);
        return function.apply(getRawElementBlock(), startValueOffset, endValueOffset - startValueOffset);
    }

    protected final void checkReadablePosition(int position)
    {
        if (position < 0 || position >= getPositionCount()) {
            throw new IllegalArgumentException("position is not valid");
        }
    }

    public interface ArrayBlockFunction<T>
    {
        T apply(Block block, int startPosition, int length);
    }

    @Override
    public Block getBlockUnchecked(int internalPosition)
    {
        int startValueOffset = getOffsets()[internalPosition];
        int endValueOffset = getOffsets()[internalPosition + 1];
        return getRawElementBlock().getRegion(startValueOffset, endValueOffset - startValueOffset);
    }

    @Override
    public boolean isNullUnchecked(int internalPosition)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check position against getPositionCount() before access
  2. Fix off-by-one or stale positionCount in the calling loop
  3. Verify the block was not reused after being closed or truncated
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-common/src/main/java/com/facebook/presto/common/block/AbstractArrayBlock.java:303 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/ca1ef293a83a05e3. Report an issue: GitHub.