quarkusio/quarkus · error · IllegalArgumentException
Invalid parameter index '${index}' used when obtaining param
Error message
Invalid parameter index '${index}' used when obtaining parameter values What it means
This error is thrown by ComputedParamContextImpl.getMethodParameterFromContext when resolving a @PathParam/@QueryParam-style template expression that references a method parameter by index, but the index is out of range of the actual client method parameters. It means the rest client generated a parameter reference that does not exist in the invoked method signature. The library throws it to fail fast instead of returning null for a missing parameter value.
Source
Thrown at extensions/resteasy-reactive/rest-client/runtime/src/main/java/io/quarkus/rest/client/reactive/runtime/ComputedParamContextImpl.java:60
@Override
public String name() {
return name;
}
@Override
public List<MethodParameter> methodParameters() {
return parameters;
}
public static Object getMethodParameterFromContext(ClientRequestContext context, int index) {
Object property = context.getProperty(INVOKED_METHOD_PARAMETERS_PROP);
if (property == null) {
throw new IllegalStateException(
"property " + INVOKED_METHOD_PARAMETERS_PROP + " should have been part of the client context");
}
List<Object> methodParameterValues = (List<Object>) property;
if (index > methodParameterValues.size() - 1) {
throw new IllegalArgumentException("Invalid parameter index '" + index + "' used when obtaining parameter values");
}
return methodParameterValues.get(index);
}
private static class MethodParameterImpl implements MethodParameter {
private final Object value;
private MethodParameterImpl(Object value) {
this.value = value;
}
@Override
public Object value() {
return value;
}
}
}View on GitHub (pinned to e1c734241f)
Solutions
- Fix the template/computed parameter index in the client method annotations to match the actual parameter positions
- Restore the removed/renamed method parameter that the index refers to
- Rebuild the project so generated rest-client code is regenerated in sync with the interface
Example fix
// before
@Path("/{id}/items/{0}")
Response get(@PathParam("id") String id);
// after
@Path("/{id}/items/{item}")
Response get(@PathParam("id") String id, @PathParam("item") String item); Defensive patterns
Strategy: validation
Validate before calling
int idx = 0; // index you intend to use
java.util.List<?> params = getInvokedMethodParameters(ctx); // or count method params
if (idx < 0 || idx >= params.size()) {
throw new IllegalStateException("Parameter index " + idx + " out of range (" + params.size() + " params)");
} Type guard
boolean isValidParamIndex(int index, int paramCount) {
return index >= 0 && index < paramCount;
} Try / catch
try {
Object v = ctx.getMethodParameter(index);
} catch (IllegalArgumentException e) {
log.warn("Bad template parameter index: {}", e.getMessage());
v = null; // or fall back to a default value
} Prevention
- Prefer named path/query parameters over positional indices
- Rebuild after every change to a client interface method signature
- Keep custom param-supplying filters/providers in sync with method parameter counts
When it happens
Trigger: Calling a REST client interface method whose @BeanParam or template expression (e.g. {0} or a computed parameter) references parameter index N while the method has fewer than N+1 parameters; typically caused by mismatched generated code or hand-written custom param providers using wrong indices.
Common situations: After refactoring a client interface method signature (removing/adding parameters) without updating annotation/computed-parameter indices; misconfigured ClientRequestFilter or custom ParamConverter provider supplying INVOKED_METHOD_PARAMETERS_PROP incorrectly.
Related errors
- proxyHost must not be null
- Invalid port number
- ExecutorService must not be null
- Name cannot start with '/':${name}
- Predicate already set
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/d14fdc2c7d6c2b98.
Report an issue: GitHub.