{"record":{"id":"7008b2d2d8f286da","repo":"apache/pulsar","slug":"s-instance-id-is-not-provided","errorCode":null,"errorMessage":"%s Instance Id is not provided","messagePattern":"(.+?) Instance Id is not provided","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java","lineNumber":1564,"sourceCode":"    private void validateListFunctionRequestParams(final String tenant, final String namespace)\n            throws IllegalArgumentException {\n\n        if (tenant == null) {\n            throw new IllegalArgumentException(\"Tenant is not provided\");\n        }\n        if (namespace == null) {\n            throw new IllegalArgumentException(\"Namespace is not provided\");\n        }\n    }\n\n    protected void validateGetFunctionInstanceRequestParams(final String tenant,\n                                                            final String namespace,\n                                                            final String componentName,\n                                                            final FunctionDetails.ComponentType componentType,\n                                                            final String instanceId) throws IllegalArgumentException {\n        validateGetFunctionRequestParams(tenant, namespace, componentName, componentType);\n        if (instanceId == null) {\n            throw new IllegalArgumentException(String.format(\"%s Instance Id is not provided\", componentType));\n        }\n    }\n\n    protected void validateGetFunctionRequestParams(String tenant, String namespace, String subject,\n                                                    FunctionDetails.ComponentType componentType)\n            throws IllegalArgumentException {\n\n        if (tenant == null) {\n            throw new IllegalArgumentException(\"Tenant is not provided\");\n        }\n        if (namespace == null) {\n            throw new IllegalArgumentException(\"Namespace is not provided\");\n        }\n        if (subject == null) {\n            throw new IllegalArgumentException(ComponentTypeUtils.toString(componentType) + \" name is not provided\");\n        }\n    }\n","sourceCodeStart":1546,"sourceCodeEnd":1582,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java#L1546-L1582","documentation":"An IllegalArgumentException thrown by ComponentImpl.validateGetFunctionInstanceRequestParams when the instanceId is null while fetching a specific function/sink/source instance status or stats. It first delegates to validateGetFunctionRequestParams, then checks the instance identifier.","triggerScenarios":"Calling getFunctionInstance APIs (e.g. GET .../functions/{tenant}/{namespace}/{function}/{instanceId} via admin API getFunctionStatus with a null instanceId argument).","commonSituations":"Loop over instances where the instance index variable was never set; request built from config where the instance id field is absent; mixing up getFunctionStatus (all instances) with getFunctionInstanceStatus (per instance) calls.","solutions":["Pass the instance id (integer index of the instance) to the call","If you want aggregate status, call the non-instance variant (getFunctionStatus) instead","Fix config wiring so the instance id is populated"],"exampleFix":"// before\nadmin.functions().getFunctionStatus(\"public\", \"default\", \"my-fn\", null);\n// after\nadmin.functions().getFunctionStatus(\"public\", \"default\", \"my-fn\", 0);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(instanceId, \"instanceId must be provided for instance-level status calls\");","typeGuard":"static boolean hasInstanceId(Integer instanceId) {\n    return instanceId != null && instanceId >= 0;\n}","tryCatchPattern":"try {\n    return admin.functions().getFunctionStatus(tenant, ns, name, instanceId);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().endsWith(\"Instance Id is not provided\")) {\n        // use aggregate API instead\n        return admin.functions().getFunctionStatus(tenant, ns, name);\n    }\n    throw e;\n}","preventionTips":["Use the aggregate getFunctionStatus API when you do not need a specific instance","Iterate instance ids from 0 to parallelism-1 when fetching all instances","Do not confuse instance-level and function-level status APIs"],"tags":["validation","missing-parameter","pulsar-functions","illegal-argument"],"backgroundTag":"missing-required-parameter","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"}