{"record":{"id":"523a249ff329ad59","repo":"apache/pulsar","slug":"function-package-is-not-provided","errorCode":null,"errorMessage":"Function package is not provided","messagePattern":"Function package is not provided","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java","lineNumber":822,"sourceCode":"                if (function == null) {\n                    throw new IllegalArgumentException(String.format(\"No Function %s found\", archive));\n                }\n                functionPackage = function.getFunctionPackage();\n            }\n        }\n        boolean shouldCloseFunctionPackage = false;\n        try {\n            if (functionConfig.getRuntime() == FunctionConfig.Runtime.JAVA) {\n                // if function is not builtin, attempt to extract classloader from package file if it exists\n                if (functionPackage == null && componentPackageFile != null) {\n                    functionPackage =\n                            new FunctionFilePackage(componentPackageFile, workerConfig.getNarExtractionDirectory(),\n                                    workerConfig.getEnableClassloadingOfExternalFiles(), FunctionDefinition.class);\n                    shouldCloseFunctionPackage = true;\n                }\n\n                if (functionPackage == null) {\n                    throw new IllegalArgumentException(\"Function package is not provided\");\n                }\n\n                FunctionConfigUtils.ExtractedFunctionDetails functionDetails = FunctionConfigUtils.validateJavaFunction(\n                        functionConfig, functionPackage);\n                return FunctionConfigUtils.convert(functionConfig, functionDetails);\n            } else {\n                FunctionConfigUtils.validateNonJavaFunction(functionConfig);\n                return FunctionConfigUtils.convert(functionConfig);\n            }\n        } finally {\n            if (shouldCloseFunctionPackage && functionPackage instanceof AutoCloseable) {\n                try {\n                    ((AutoCloseable) functionPackage).close();\n                } catch (Exception e) {\n                    log.error().exception(e).log(\"Failed to close function file\");\n                }\n            }\n        }","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java#L804-L840","documentation":"IllegalArgumentException thrown by validateUpdateRequestParams when the function runtime is JAVA but no function package can be resolved: the config's jar is not a builtin reference (so functionPackage stayed null) and no uploaded package file (componentPackageFile) was supplied. Java functions require a code package so the worker can validate and load the function class.","triggerScenarios":"registerFunction/updateFunction called with a Java-runtime config, no builtin:// jar, functionPkgUrl not resolvable to a local file, and no multipart file upload; e.g. passing only a package URL the worker cannot fetch, or omitting the file part in the multipart form.","commonSituations":"Client sends a fileUpload field name the endpoint doesn't expect, so the InputStream binds null; using pkgUrl with a scheme the worker can't fetch at validation time; registering a Java function through the V2 JSON API without attaching the jar; automation that assumes builtin but config still points to a custom jar.","solutions":["Attach the function jar in the multipart upload (correct form field name) or provide a reachable functionPkgUrl (http(s)://, file:// on the worker, or builtin://).","If the code is a built-in connector, prefix the jar with builtin:// so validation resolves it via FunctionsManager.","Verify the package URL is accessible from the worker host, not just the client, at registration time."],"exampleFix":"// before\nregisterFunction(tenant, ns, name, null /* no file */, null, \"http://internal/repo/fn.jar\", config);\n// after\nregisterFunction(tenant, ns, name, jarInputStream, fileDetail, null, config); // upload jar directly","handlingStrategy":"validation","validationCode":"boolean hasPackage = (jar != null && jar.startsWith(\"builtin://\"))\n    || uploadedInputStream != null\n    || (functionPkgUrl != null && isUrlReachableFromWorker(functionPkgUrl));\nif (!hasPackage) throw new IllegalArgumentException(\"provide builtin:// jar, uploaded file, or reachable pkgUrl\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always attach the jar multipart part (or a reachable package URL) when registering Java functions.","Confirm package URLs are resolvable from the worker host, not only the client.","For built-in code, always prefix the jar value with builtin://."],"tags":["rest","bad-request","missing-package","pulsar-functions"],"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"}