{"record":{"id":"babce045cde98bca","repo":"quarkusio/quarkus","slug":"unsupported-base-operand","errorCode":null,"errorMessage":"Unsupported base operand: ","messagePattern":"Unsupported base operand: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java","lineNumber":682,"sourceCode":"            Object base = context.getBase();\n            return base != null && (base instanceof Integer || base instanceof Long) && context.getParams().size() == 1\n                    && appliesToName(context.getName());\n        }\n\n        @Override\n        public CompletionStage<Object> resolve(EvalContext context) {\n            return context.evaluate(context.getParams().get(0)).thenApply(new Function<Object, Object>() {\n                @Override\n                public Object apply(Object param) {\n                    Object base = context.getBase();\n                    if (param instanceof Integer) {\n                        Integer intParam = (Integer) param;\n                        if (base instanceof Integer) {\n                            return compute((Integer) base, intParam);\n                        } else if (base instanceof Long) {\n                            return compute((Long) base, intParam);\n                        } else {\n                            throw new IllegalStateException(\"Unsupported base operand: \" + base.getClass());\n                        }\n                    } else if (param instanceof Long) {\n                        Long longParam = (Long) param;\n                        if (base instanceof Integer) {\n                            return compute((Integer) base, longParam);\n                        } else if (base instanceof Long) {\n                            return compute((Long) base, longParam);\n                        } else {\n                            throw new IllegalStateException(\"Unsupported base operand: \" + base.getClass());\n                        }\n                    }\n                    return Results.notFound(context);\n                }\n            });\n        }\n\n        protected abstract boolean appliesToName(String name);\n","sourceCodeStart":664,"sourceCodeEnd":700,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/ValueResolvers.java#L664-L700","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Convert the base to int/long in the template first, e.g. `{myValue.intValue.plus(1)}`.","In application code, normalize the value to Integer or Long before exposing it to the template.","If you need floating-point arithmetic, use the appropriate resolver or perform the computation in Java code and pass the result as template data."],"exampleFix":"// before (template)\n{myDouble.plus(2)}\n// after (template)\n{myDouble.intValue.plus(2)}","handlingStrategy":"type-guard","validationCode":"// before putting data into the template\nif (!(value instanceof Integer || value instanceof Long)) {\n    value = ((Number) value).intValue();\n}","typeGuard":"boolean isSupportedArithmeticBase(Object v) {\n    return v instanceof Integer || v instanceof Long;\n}","tryCatchPattern":"try {\n    return template.render(data);\n} catch (IllegalStateException | TemplateException e) {\n    log.warn(\"arithmetic operand unsupported\", e);\n    return fallbackRender(data);\n}","preventionTips":["Normalize numeric template data to Integer/Long before rendering","Avoid Double/Float/BigDecimal bases for plus/minus/times/divide in templates","Add template smoke tests for expressions that perform arithmetic"],"tags":["qute","arithmetic","type-mismatch","template"],"backgroundTag":"unsupported-operand-type","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}