apache/pulsar · error · WebApplicationException

${fullFunctionName} doesn't exist

Error message

${fullFunctionName} doesn't exist

What it means

restartFunctionInstance looks up the Assignment for the requested tenant/namespace/function/instanceId. If findAssignment returns null, no such instance is currently scheduled, so the manager throws a WebApplicationException (BAD_REQUEST) with the message '<tenant>/<namespace>/<function>/<instanceId> doesn't exist'.

Source

Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java:370

     * @param assignments assignments to remove
     */
    public synchronized void removeAssignments(Collection<Assignment> assignments) {
        for (Assignment assignment : assignments) {
            this.deleteAssignment(assignment);
        }
    }

    public synchronized void restartFunctionInstance(String tenant, String namespace,
                                                     String functionName, int instanceId, URI uri) throws Exception {
        if (runtimeFactory.externallyManaged()) {
            throw new WebApplicationException(Response.serverError().status(Status.NOT_IMPLEMENTED)
                    .type(MediaType.APPLICATION_JSON)
                    .entity(new ErrorData("Externally managed schedulers can't do per instance stop")).build());
        }
        Assignment assignment = this.findAssignment(tenant, namespace, functionName, instanceId);
        final String fullFunctionName = String.format("%s/%s/%s/%s", tenant, namespace, functionName, instanceId);
        if (assignment == null) {
            throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST)
                    .type(MediaType.APPLICATION_JSON)
                    .entity(new ErrorData(fullFunctionName + " doesn't exist")).build());
        }

        final String assignedWorkerId = assignment.getWorkerId();
        final String workerId = this.workerConfig.getWorkerId();

        if (assignedWorkerId.equals(workerId)) {
            stopFunction(FunctionCommon.getFullyQualifiedInstanceId(assignment.getInstance()), true);
            return;
        } else {
            // query other worker
            List<WorkerInfo> workerInfoList = this.membershipManager.getCurrentMembership();
            WorkerInfo workerInfo = null;
            for (WorkerInfo entry : workerInfoList) {
                if (assignment.getWorkerId().equals(entry.getWorkerId())) {
                    workerInfo = entry;
                }

View on GitHub (pinned to 820761864e)

Solutions

  1. Verify the function exists and check its parallelism via GET function before restarting a specific instanceId.
  2. Ensure the request goes to the leader worker (only the leader has authoritative assignment state).
  3. Use restartFunctionInstances (whole function) if you don't need per-instance targeting.
  4. Retry shortly after function creation — scheduling may not have completed yet.

Example fix

// before
admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);
// after
FunctionConfig cfg = admin.functions().getFunction(tenant, ns, fn);
if (instanceId >= 0 && instanceId < cfg.getParallelism()) {
    admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);
} else {
    throw new IllegalArgumentException("instanceId out of range: " + instanceId);
}
Defensive patterns

Strategy: validation

Validate before calling

FunctionConfig cfg = admin.functions().getFunction(tenant, ns, fn); // throws 404 if absent
if (instanceId < 0 || instanceId >= cfg.getParallelism()) {
    throw new IllegalArgumentException(
        "instanceId " + instanceId + " out of range for parallelism " + cfg.getParallelism());
}

Try / catch

try {
    admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);
} catch (PulsarAdminException e) {
    if (e.getStatusCode() == 400 && e.getMessage().contains("doesn't exist")) {
        // verify function exists / instanceId range, then retry or restart whole function
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling restartFunctionInstance for an instanceId that has no assignment — the function is not deployed, is deployed with fewer instances than the requested instanceId, was already deleted, or the local worker's assignment cache hasn't been populated yet.

Common situations: Typo in function name or instance id out of range (e.g. instanceId 3 on a function with parallelism 2); calling restart right after function creation before scheduling completes; requesting on a worker that isn't the leader and has no assignment info; function deleted by another admin.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/60ca8befabbab3f3. Report an issue: GitHub.