apache/pulsar · warning · RestException
%s %s doesn't have instance with id %s
Error message
%s %s doesn't have instance with id %s
What it means
The parsed instanceId is out of range: it is negative or >= the function's configured parallelism, so getFunctionsInstanceStats throws HTTP 400 '%s %s doesn't have instance with id %s'. The function is valid but simply has no such instance.
Source
Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java:1005
}
FunctionMetaData functionMetaData =
functionMetaDataManager.getFunctionMetaData(tenant, namespace, componentName);
if (!InstanceUtils.calculateSubjectType(functionMetaData.getFunctionDetails()).equals(componentType)) {
log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", componentName)
.attr("componentType", ComponentTypeUtils.toString(componentType)).log("/ / is not a");
throw new RestException(Status.NOT_FOUND,
String.format("%s %s doesn't exist", ComponentTypeUtils.toString(componentType), componentName));
}
int instanceIdInt = Integer.parseInt(instanceId);
if (instanceIdInt < 0 || instanceIdInt >= functionMetaData.getFunctionDetails().getParallelism()) {
log.error().attr("componentType", ComponentTypeUtils.toString(componentType)).attr("tenant", tenant)
.attr("namespace", namespace).attr("componentName", componentName)
.log("instanceId in get Stats out of bounds @ / / /");
throw new RestException(Status.BAD_REQUEST,
String.format("%s %s doesn't have instance with id %s", ComponentTypeUtils.toString(componentType),
componentName, instanceId));
}
FunctionRuntimeManager functionRuntimeManager = worker().getFunctionRuntimeManager();
FunctionInstanceStatsDataImpl functionInstanceStatsData;
try {
functionInstanceStatsData =
functionRuntimeManager.getFunctionInstanceStats(tenant, namespace, componentName,
Integer.parseInt(instanceId), uri);
} catch (WebApplicationException we) {
throw we;
} catch (Exception e) {
log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", componentName)
.exception(e).log("/ / Got Exception Getting Stats");
throw new RestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
}View on GitHub (pinned to 820761864e)
Solutions
- Fetch current parallelism via GET .../functions/{tenant}/{namespace}/{name} and only request instance ids in [0, parallelism)
- If parallelism changed recently, refresh the instance list in clients/dashboards
- Fix integer parsing so ids are non-numeric values are rejected client-side
Example fix
// before curl 'http://worker:8080/admin/v3/functions/tenant/ns/fn/5/stats' // 400, parallelism=2 // after # enumerate instances 0..parallelism-1 for i in 0 1; do curl "http://worker:8080/admin/v3/functions/tenant/ns/fn/$i/stats"; done
Defensive patterns
Strategy: validation
Validate before calling
// Java: bound-check instanceId against current parallelism
FunctionConfig cfg = admin.functions().getFunction(tenant, namespace, fn);
int parallelism = cfg.getParallelism();
if (instanceId < 0 || instanceId >= parallelism) {
throw new IllegalArgumentException(
"instanceId " + instanceId + " out of range [0," + parallelism + ")");
} Try / catch
// Java
try {
FunctionInstanceStatsData s = admin.functions().getFunctionInstanceStats(tenant, namespace, fn, id);
} catch (PulsarAdminException e) {
if (e.getStatusCode() == 400) { /* refresh parallelism and re-derive valid instance ids */ }
} Prevention
- Fetch parallelism from the function config, never cache instance counts
- Enumerate instances as 0..parallelism-1 (exclusive upper bound)
- Refresh instance lists after any update that changes parallelism
When it happens
Trigger: GET .../{tenant}/{namespace}/{name}/{instanceId}/stats with instanceId >= parallelism (e.g. asking for instance 3 of a parallelism-1 function) or a negative/non-numeric id; also after parallelism was lowered while clients cache old instance counts.
Common situations: Dashboards that discover instance count once and keep polling after an update reduced parallelism; off-by-one loops (<= instead of <); deleting instances after update.
Related errors
- <validation message from IllegalArgumentException>
- Function in trigger function has more than 1 input topics
- Function in trigger function has unidentified topic
- %s Package is not provided
- {e.getMessage()}
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/8596b42eeb4695ef.
Report an issue: GitHub.