prestodb/presto · error · IllegalStateException

Expected current entry to be closed but was opened

Error message

Expected current entry to be closed but was opened

What it means

appendStructure on ArrayBlockBuilder requires no entry currently open (newEntry begun but not closed); this IllegalStateException fires when a nested or unclosed appendStructure call tries to start another structure entry.

Source

Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlockBuilder.java:161

    @Override
    public boolean mayHaveNull()
    {
        return hasNullValue;
    }

    @Override
    public boolean isNull(int position)
    {
        checkReadablePosition(position);
        return hasNullValue && valueIsNull[position];
    }

    @Override
    public BlockBuilder appendStructure(Block block)
    {
        if (currentEntryOpened) {
            throw new IllegalStateException("Expected current entry to be closed but was opened");
        }
        currentEntryOpened = true;

        for (int i = 0; i < block.getPositionCount(); i++) {
            if (block.isNull(i)) {
                values.appendNull();
            }
            else {
                block.writePositionTo(i, values);
            }
        }

        closeEntry();
        return this;
    }

    @Override
    public Block getSingleValueBlock(int position)

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Call closeEntry() before appending the next structure
  2. Audit nested block builder usage for missing close calls on error paths
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-common/src/main/java/com/facebook/presto/common/block/ArrayBlockBuilder.java:161 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/8ec270bf834a96d6. Report an issue: GitHub.