{"record":{"id":"151c66994d98d202","repo":"apache/pulsar","slug":"validation-message-from-illegalargumentexception","errorCode":null,"errorMessage":"<validation message from IllegalArgumentException>","messagePattern":"<validation message from IllegalArgumentException>","errorType":"validation","errorClass":"RestException","httpStatus":400,"severity":"warning","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java","lineNumber":464,"sourceCode":"                                   final AuthenticationParameters authParams) {\n\n        if (!isWorkerServiceAvailable()) {\n            throwUnavailableException();\n        }\n\n        throwRestExceptionIfUnauthorizedForNamespace(tenant, namespace, componentName, \"deregister\",\n                authParams);\n\n        // validate parameters\n        try {\n            validateDeregisterRequestParams(tenant, namespace, componentName, componentType);\n        } catch (IllegalArgumentException e) {\n            log.error().attr(\"componentType\", ComponentTypeUtils.toString(componentType)).attr(\"tenant\", tenant)\n\n                    .attr(\"namespace\", namespace).attr(\"componentName\", componentName).exception(e)\n\n                    .log(\"Invalid deregister request @ / / /\");\n            throw new RestException(Status.BAD_REQUEST, e.getMessage());\n        }\n\n        FunctionMetaDataManager functionMetaDataManager = worker().getFunctionMetaDataManager();\n        if (!functionMetaDataManager.containsFunction(tenant, namespace, componentName)) {\n            log.error().attr(\"componentType\", ComponentTypeUtils.toString(componentType)).attr(\"tenant\", tenant)\n\n                    .attr(\"namespace\", namespace).attr(\"componentName\", componentName)\n\n                    .log(\"to deregister does not exist @ / / /\");\n            throw new RestException(Status.NOT_FOUND,\n                    String.format(\"%s %s doesn't exist\", ComponentTypeUtils.toString(componentType), componentName));\n        }\n        FunctionMetaData functionMetaData =\n                functionMetaDataManager.getFunctionMetaData(tenant, namespace, componentName);\n\n        if (!InstanceUtils.calculateSubjectType(functionMetaData.getFunctionDetails()).equals(componentType)) {\n            log.error().attr(\"tenant\", tenant).attr(\"namespace\", namespace).attr(\"componentName\", componentName)\n","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java#L446-L482","documentation":"deregisterFunction validates the tenant/namespace/componentName arguments via an internal validation method that throws IllegalArgumentException; ComponentImpl catches it and converts it to HTTP 400 BAD_REQUEST RestException carrying the validation message. It indicates a malformed or invalid deregister request, not a missing function.","triggerScenarios":"Deregistering a function/sink/source with missing or malformed tenant, namespace, or name (null, empty string, illegal characters); wrong component type parameters; API misuse where path/query parameters are not populated.","commonSituations":"Client code building the REST URL with blank variables; names containing invalid characters (slashes, spaces); SDK/CLI versions passing null for optional parameters; automation templates with unexpanded placeholders.","solutions":["Check the request: ensure tenant, namespace, and component name are non-empty and valid (no illegal characters, correct case).","Fix the client/CLI invocation or URL template so parameters are properly populated and encoded.","Validate inputs before calling the API (null/empty/regex checks)."],"exampleFix":"// before\nadmin.functions().deleteFunction(tenant, ns, null); // NPE -> IllegalArgumentException -> 400\n// after\nif (tenant == null || ns == null || fn == null || fn.isBlank()) {\n    throw new IllegalArgumentException(\"tenant, namespace and function name are required\");\n}\nadmin.functions().deleteFunction(tenant, ns, fn);","handlingStrategy":"validation","validationCode":"// validate parameters before calling deregister\nObjects.requireNonNull(tenant, \"tenant required\");\nObjects.requireNonNull(namespace, \"namespace required\");\nObjects.requireNonNull(componentName, \"component name required\");\nif (tenant.isBlank() || namespace.isBlank() || componentName.isBlank()\n        || !componentName.matches(\"[a-zA-Z0-9_:-]+\")) {\n    throw new IllegalArgumentException(\"Invalid tenant/namespace/name\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    deregisterFunction(tenant, namespace, componentName, componentType);\n} catch (RestException e) {\n    if (e.getResponse().getStatus() == 400) {\n        // fix request parameters per e.getMessage()\n    }\n    throw e;\n}","preventionTips":["Never pass null/empty tenant, namespace, or component names","Encode names properly in REST URLs","Validate identifiers (charset, casing) before API calls","Expand URL-template placeholders fully in automation"],"tags":["pulsar-functions","rest-api","validation","bad-request"],"backgroundTag":"invalid-request-parameters","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}