quarkusio/quarkus · error

Unsupported base operand:

Error message

Unsupported base operand: 

What it means

Qute's IntArithmeticResolver (used by arithmetic value resolvers such as math operators) only supports Integer and Long base operands. This IllegalStateException is thrown when the evaluated base object is neither Integer nor Long at the point of computation, which normally means the appliesTo check and the resolve logic saw different types (e.g. the base was reassigned/evaluated asynchronously).

Source

Thrown at independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java:682

            Object base = context.getBase();
            return base != null && (base instanceof Integer || base instanceof Long) && context.getParams().size() == 1
                    && appliesToName(context.getName());
        }

        @Override
        public CompletionStage<Object> resolve(EvalContext context) {
            return context.evaluate(context.getParams().get(0)).thenApply(new Function<Object, Object>() {
                @Override
                public Object apply(Object param) {
                    Object base = context.getBase();
                    if (param instanceof Integer) {
                        Integer intParam = (Integer) param;
                        if (base instanceof Integer) {
                            return compute((Integer) base, intParam);
                        } else if (base instanceof Long) {
                            return compute((Long) base, intParam);
                        } else {
                            throw new IllegalStateException("Unsupported base operand: " + base.getClass());
                        }
                    } else if (param instanceof Long) {
                        Long longParam = (Long) param;
                        if (base instanceof Integer) {
                            return compute((Integer) base, longParam);
                        } else if (base instanceof Long) {
                            return compute((Long) base, longParam);
                        } else {
                            throw new IllegalStateException("Unsupported base operand: " + base.getClass());
                        }
                    }
                    return Results.notFound(context);
                }
            });
        }

        protected abstract boolean appliesToName(String name);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Convert the base to int/long in the template first, e.g. `{myValue.intValue.plus(1)}`.
  2. In application code, normalize the value to Integer or Long before exposing it to the template.
  3. If you need floating-point arithmetic, use the appropriate resolver or perform the computation in Java code and pass the result as template data.

Example fix

// before (template)
{myDouble.plus(2)}
// after (template)
{myDouble.intValue.plus(2)}
Defensive patterns

Strategy: type-guard

Validate before calling

// before putting data into the template
if (!(value instanceof Integer || value instanceof Long)) {
    value = ((Number) value).intValue();
}

Type guard

boolean isSupportedArithmeticBase(Object v) {
    return v instanceof Integer || v instanceof Long;
}

Try / catch

try {
    return template.render(data);
} catch (IllegalStateException | TemplateException e) {
    log.warn("arithmetic operand unsupported", e);
    return fallbackRender(data);
}

Prevention

When it happens

Trigger: An arithmetic resolver operation (e.g. plus/minus/times/divide) where the evaluated parameter is an Integer but `context.getBase()` is some other Number type (Float, Double, BigInteger, or a wrapped/null-derived value), hitting ValueResolvers.java:682.

Common situations: Applying integer arithmetic helpers to floating-point or BigInteger/BigDecimal values; a custom resolver or expression wrapper changing the base type between appliesTo and resolve; version upgrades where a value that used to be Integer now arrives as Double.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/babce045cde98bca. Report an issue: GitHub.