{"record":{"id":"60ca8befabbab3f3","repo":"apache/pulsar","slug":"fullfunctionname-doesn-t-exist","errorCode":null,"errorMessage":"${fullFunctionName} doesn't exist","messagePattern":"(.+?) doesn't exist","errorType":"http","errorClass":"WebApplicationException","httpStatus":400,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java","lineNumber":370,"sourceCode":"     * @param assignments assignments to remove\n     */\n    public synchronized void removeAssignments(Collection<Assignment> assignments) {\n        for (Assignment assignment : assignments) {\n            this.deleteAssignment(assignment);\n        }\n    }\n\n    public synchronized void restartFunctionInstance(String tenant, String namespace,\n                                                     String functionName, int instanceId, URI uri) throws Exception {\n        if (runtimeFactory.externallyManaged()) {\n            throw new WebApplicationException(Response.serverError().status(Status.NOT_IMPLEMENTED)\n                    .type(MediaType.APPLICATION_JSON)\n                    .entity(new ErrorData(\"Externally managed schedulers can't do per instance stop\")).build());\n        }\n        Assignment assignment = this.findAssignment(tenant, namespace, functionName, instanceId);\n        final String fullFunctionName = String.format(\"%s/%s/%s/%s\", tenant, namespace, functionName, instanceId);\n        if (assignment == null) {\n            throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST)\n                    .type(MediaType.APPLICATION_JSON)\n                    .entity(new ErrorData(fullFunctionName + \" doesn't exist\")).build());\n        }\n\n        final String assignedWorkerId = assignment.getWorkerId();\n        final String workerId = this.workerConfig.getWorkerId();\n\n        if (assignedWorkerId.equals(workerId)) {\n            stopFunction(FunctionCommon.getFullyQualifiedInstanceId(assignment.getInstance()), true);\n            return;\n        } else {\n            // query other worker\n            List<WorkerInfo> workerInfoList = this.membershipManager.getCurrentMembership();\n            WorkerInfo workerInfo = null;\n            for (WorkerInfo entry : workerInfoList) {\n                if (assignment.getWorkerId().equals(entry.getWorkerId())) {\n                    workerInfo = entry;\n                }","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/FunctionRuntimeManager.java#L352-L388","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the function exists and check its parallelism via GET function before restarting a specific instanceId.","Ensure the request goes to the leader worker (only the leader has authoritative assignment state).","Use restartFunctionInstances (whole function) if you don't need per-instance targeting.","Retry shortly after function creation — scheduling may not have completed yet."],"exampleFix":"// before\nadmin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);\n// after\nFunctionConfig cfg = admin.functions().getFunction(tenant, ns, fn);\nif (instanceId >= 0 && instanceId < cfg.getParallelism()) {\n    admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);\n} else {\n    throw new IllegalArgumentException(\"instanceId out of range: \" + instanceId);\n}","handlingStrategy":"validation","validationCode":"FunctionConfig cfg = admin.functions().getFunction(tenant, ns, fn); // throws 404 if absent\nif (instanceId < 0 || instanceId >= cfg.getParallelism()) {\n    throw new IllegalArgumentException(\n        \"instanceId \" + instanceId + \" out of range for parallelism \" + cfg.getParallelism());\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.functions().restartFunctionInstance(tenant, ns, fn, instanceId);\n} catch (PulsarAdminException e) {\n    if (e.getStatusCode() == 400 && e.getMessage().contains(\"doesn't exist\")) {\n        // verify function exists / instanceId range, then retry or restart whole function\n    } else {\n        throw e;\n    }\n}","preventionTips":["Validate function existence and parallelism bounds before per-instance operations.","Send per-instance operations to the leader worker, which holds authoritative assignment state.","Allow a short delay after function creation before instance-level management calls."],"tags":["pulsar-functions","not-found","http-400"],"backgroundTag":"function-instance-not-found","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}