{"record":{"id":"64223b1fdc198594","repo":"apache/pulsar","slug":"key-is-not-provided","errorCode":null,"errorMessage":"Key is not provided","messagePattern":"Key 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":1614,"sourceCode":"    }\n\n    private void validateFunctionStateParams(final String tenant,\n                                             final String namespace,\n                                             final String functionName,\n                                             final String key)\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 (functionName == null) {\n            throw new IllegalArgumentException(ComponentTypeUtils.toString(componentType) + \" name is not provided\");\n        }\n        if (key == null) {\n            throw new IllegalArgumentException(\"Key is not provided\");\n        }\n    }\n\n    private String getFunctionCodeBuiltin(FunctionDetails functionDetails,\n                                          FunctionDetails.ComponentType componentType) {\n        if (componentType == FunctionDetails.ComponentType.SOURCE && functionDetails.hasSource()) {\n            SourceSpec sourceSpec = functionDetails.getSource();\n            if (!isEmpty(sourceSpec.getBuiltin())) {\n                return sourceSpec.getBuiltin();\n            }\n        }\n\n        if (componentType == FunctionDetails.ComponentType.SINK && functionDetails.hasSink()) {\n            SinkSpec sinkSpec = functionDetails.getSink();\n            if (!isEmpty(sinkSpec.getBuiltin())) {\n                return sinkSpec.getBuiltin();\n            }\n        }","sourceCodeStart":1596,"sourceCodeEnd":1632,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java#L1596-L1632","documentation":"Thrown by ComponentImpl.validateFunctionStateParams when the state key is missing. The key identifies the individual state entry (e.g. a counter) stored for the function, so a null key makes the state request meaningless.","triggerScenarios":"Calling ComponentImpl.getFunctionState or updateFunctionState with key == null; REST GET/POST to /functions/{tenant}/{namespace}/{functionName}/state/{key} with an empty key.","commonSituations":"Key argument dropped when calling programmatically; URL path built with an empty key segment; CLI missing --key option.","solutions":["Provide the state key in the call/path.","Validate the key is non-null (and usually non-empty) before calling.","If the key is computed, check the computation didn't return null."],"exampleFix":"// before\nworker.getFunctionState(\"public\", \"ns\", \"fn\", null);\n// after\nif (key == null || key.isEmpty()) { throw new IllegalArgumentException(\"state key required\"); }\nworker.getFunctionState(\"public\", \"ns\", \"fn\", key);","handlingStrategy":"validation","validationCode":"if (key == null || key.isEmpty()) throw new IllegalArgumentException(\"state key required\");","typeGuard":"boolean isProvided(String s) { return s != null && !s.isEmpty(); }","tryCatchPattern":"try { state = admin.functions().getFunctionState(t, ns, fn, key); }\ncatch (IllegalArgumentException e) { /* log missing state key */ }","preventionTips":["Pass keys as named constants where possible","Check computed keys for null/empty before the API call"],"tags":["pulsar-functions","missing-parameter","function-state","validation"],"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"}