{"record":{"id":"edabba1162ac0310","repo":"apache/pulsar","slug":"encountered-error-s-when-getting-s-package-fro","errorCode":null,"errorMessage":"Encountered error \"%s\" when getting %s package from %s","messagePattern":"Encountered error \"(.+?)\" when getting (.+?) package from (.+?)","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":1936,"sourceCode":"        worker.getBrokerAdmin().packages().download(packageName, file.toString());\n        return file;\n    }\n\n    protected File getPackageFile(FunctionDetails.ComponentType componentType, String functionPkgUrl,\n                                  String existingPackagePath, InputStream uploadedInputStream)\n            throws IOException, PulsarAdminException {\n        File componentPackageFile = null;\n        if (isNotBlank(functionPkgUrl)) {\n            componentPackageFile = getPackageFile(componentType, functionPkgUrl);\n        } else if (existingPackagePath.startsWith(Utils.FILE) || existingPackagePath.startsWith(Utils.HTTP)) {\n            if (!worker().getPackageUrlValidator().isValidPackageUrl(componentType, existingPackagePath)) {\n                throw new IllegalArgumentException(\"Function Package url is not valid.\"\n                        + \"supported url (http/https/file)\");\n            }\n            try {\n                componentPackageFile = FunctionCommon.extractFileFromPkgURL(existingPackagePath);\n            } catch (Exception e) {\n                throw new IllegalArgumentException(String.format(\"Encountered error \\\"%s\\\" \"\n                                + \"when getting %s package from %s\", e.getMessage(),\n                        ComponentTypeUtils.toString(componentType), existingPackagePath));\n            }\n        } else if (Utils.hasPackageTypePrefix(existingPackagePath)) {\n            componentPackageFile = getPackageFile(componentType, existingPackagePath);\n        } else if (uploadedInputStream != null) {\n            componentPackageFile = WorkerUtils.dumpToTmpFile(uploadedInputStream);\n        } else if (!existingPackagePath.startsWith(Utils.BUILTIN)) {\n            componentPackageFile = FunctionCommon.createPkgTempFile();\n            componentPackageFile.deleteOnExit();\n            if (worker().getWorkerConfig().isFunctionsWorkerEnablePackageManagement()) {\n                worker().getBrokerAdmin().packages().download(\n                        existingPackagePath,\n                        componentPackageFile.getAbsolutePath());\n            } else {\n                WorkerUtils.downloadFromBookkeeper(worker().getDlogNamespace(),\n                        componentPackageFile, existingPackagePath);\n            }","sourceCodeStart":1918,"sourceCodeEnd":1954,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java#L1918-L1954","documentation":"IllegalArgumentException wrapping the failure of FunctionCommon.extractFileFromPkgURL when the worker tried to download/extract a component package from a validated http/https/file existingPackagePath. The URL scheme was accepted but fetching or unpacking the archive failed, and the original exception message is embedded via %s.","triggerScenarios":"Registering/updating a function, sink, or source with existingPackagePath starting with http(s):// or file:// where: the remote HTTP(S) server is unreachable or returns 404/500; the file:// path does not exist or is unreadable on the worker; the downloaded file is corrupt or not a valid archive.","commonSituations":"Package hosted on an internal HTTP server that is down or moved; file:// path valid on the client machine but absent on the broker/worker hosts; firewall blocking the worker's outbound HTTP call; jar corrupted during upload or partially copied.","solutions":["Verify the package URL is reachable from the WORKER (curl the http(s) URL, or ls the file:// path on worker hosts) — the worker, not your client, fetches it.","Check the embedded cause message (%s) for the concrete failure: connection refused, 404, permission denied, etc., and fix accordingly.","Rebuild/re-upload the package if the archive is corrupt.","Use package:// URLs with the functions package management service to avoid ad-hoc HTTP/file hosting."],"exampleFix":"// before\nString existingPackagePath = \"http://internal-host/jars/exclamation.jar\"; // host unreachable from worker\n// after\nString existingPackagePath = \"http://reachable-artifact-host:8080/jars/exclamation.jar\";\n// (verify with: curl -I http://reachable-artifact-host:8080/jars/exclamation.jar from the worker host)","handlingStrategy":"try-catch","validationCode":"// pre-flight check of package reachability (run from worker host or CI)\nProcess p = new ProcessBuilder(\"curl\", \"-fsSI\", packageUrl).start();\nif (p.waitFor() != 0) {\n    throw new IllegalStateException(\"Package URL not reachable from worker: \" + packageUrl);\n}\n// for file:// URLs: Files.isReadable(Paths.get(URI.create(packageUrl)))","typeGuard":null,"tryCatchPattern":"try {\n    admin.functions().registerFunction(tenant, namespace, name, config);\n} catch (PulsarAdminException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Encountered error\")) {\n        // treat as transient/hosting problem: verify URL reachability, retry after fixing\n    }\n    throw e;\n}","preventionTips":["Host packages on a URL reachable from every Pulsar worker host, not just your client.","Curl the package URL from a worker node before deploying.","Verify file:// paths exist on all worker hosts, or switch to http(s) hosting.","Ensure the served file is a complete, valid jar/archive."],"tags":["package-download","network","io","pulsar-functions"],"backgroundTag":"package-fetch-failed","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"}