apache/cassandra · error · InvalidRequestException

Invalid 'unset' value in condition

Error message

Invalid 'unset' value in condition

What it means

ColumnCondition.toValue found an 'unset' bound value in a condition; LWT conditions cannot compare against unset values because there is nothing to compare. Raised as InvalidRequestException while binding a condition.

Solutions

  1. Provide an explicit value for the condition, or use the IS NOT/IS UNSET-style constructs where supported, instead of passing unset.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/java/org/apache/cassandra/cql3/conditions/ColumnCondition.java:155 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/e544c4b5fb00560f. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/conditions/ColumnCondition.java:155

    {
        ColumnMetadata column = columnsExpression.firstColumn();
        TableMetadata table = columnsExpression.table();
        ByteBuffer keyOrIndex = columnsExpression.element(context);
        if (column.type.isCollection())
        {
            checkNotNull(keyOrIndex, "Invalid null value for %s element access", column.type instanceof MapType ? "map" : "list");
        }
        return new ElementOrFieldAccessBound(column, table, keyOrIndex, operator, toValue(columnsExpression.type(), bindAndGetTerms(context)));
    }

    private ByteBuffer toValue(AbstractType<?> type, List<ByteBuffer> values)
    {
        if (operator.isIN())
            return ListType.getInstance(type, false).pack(values);

        ByteBuffer value = values.get(0);
        if (value == ByteBufferUtil.UNSET_BYTE_BUFFER)
            throw invalidRequest("Invalid 'unset' value in condition");

        return value;
    }

    private List<ByteBuffer> bindAndGetTerms(FunctionContext context)
    {
        List<ByteBuffer> buffers = values.bindAndGet(context);
        checkFalse(buffers == null && operator.isIN(), "Invalid null list in IN condition");
        checkFalse(buffers == Term.UNSET_LIST, "Invalid 'unset' value in condition");
        return filterUnsetValuesIfNeeded(buffers, ByteBufferUtil.UNSET_BYTE_BUFFER);
    }

    private <T> List<T> filterUnsetValuesIfNeeded(List<T> values, T unsetValue)
    {
        if (!operator.isIN())
            return values;

        List<T> filtered = new ArrayList<>(values.size());

View on GitHub (pinned to 88fd0f6a0e)