prestodb/presto · error · IllegalArgumentException

position is not valid

Error message

position is not valid

What it means

AbstractMapBlock's checkReadablePosition rejects map block accesses outside [0, positionCount). Its constructor-less throw site means any isNull/read on a stale or wrongly offset map position triggers this argument guard.

Source

Thrown at presto-common/src/main/java/com/facebook/presto/common/block/AbstractMapBlock.java:424

    }

    @Override
    public boolean isNull(int position)
    {
        checkReadablePosition(position);
        boolean[] mapIsNull = getMapIsNull();
        return mapIsNull != null && mapIsNull[position + getOffsetBase()];
    }

    public boolean isHashTablesPresent()
    {
        return getHashTables().get() != null;
    }

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

    public static class HashTables
    {
        private static final int INSTANCE_SIZE = ClassLayout.parseClass(HashTables.class).instanceSize();

        // Hash to location in map. Writes to the field by MapBlock is protected by "HashTables" monitor in MapBlock.
        // MapBlockBuilder instances have their dedicated hashTables instances, so the write accesses to the hashTables
        // fields do not need to be synchronized in that class.
        @Nullable
        private volatile int[] hashTables;

        // The number of hash tables. Each map row corresponds to one hash table if it's built.
        private int expectedHashTableCount;

        HashTables(Optional<int[]> hashTables, int expectedHashTableCount)
        {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Validate position against getPositionCount() before access
  2. Fix the caller's iteration bounds or offset arithmetic
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-common/src/main/java/com/facebook/presto/common/block/AbstractMapBlock.java:424 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/7b749613cad18e63. Report an issue: GitHub.