{"record":{"id":"6c8283fa5348f320","repo":"apache/pulsar","slug":"package-management-service-is-not-enabled-in-the-b","errorCode":null,"errorMessage":"Package Management Service is not enabled in the broker.","messagePattern":"Package Management Service is not enabled in the broker\\.","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":409,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java","lineNumber":2246,"sourceCode":"            functionWorkerService.get().initInBroker(\n                config,\n                workerConfig,\n                pulsarResources,\n                getInternalConfigurationData()\n            );\n\n            // TODO figure out how to handle errors from function worker service\n            functionWorkerService.get().start(\n                authenticationService,\n                authorizationService,\n                ErrorNotifier.getShutdownServiceImpl(this));\n            log.info(\"Function worker service started\");\n        }\n    }\n\n    public PackagesManagement getPackagesManagement() throws UnsupportedOperationException {\n        if (packagesManagement == null) {\n            throw new UnsupportedOperationException(\"Package Management Service is not enabled in the broker.\");\n        }\n        return packagesManagement;\n    }\n\n    private void startPackagesManagementService() throws IOException {\n        // TODO: using provider to initialize the packages management service.\n        this.packagesManagement = new PackagesManagementImpl(\n                config.isPackagesManagementJsonSerializationEnabled(),\n                config.isPackagesManagementAllowLegacyJavaSerialization());\n        PackagesStorageProvider storageProvider = PackagesStorageProvider\n            .newProvider(config.getPackagesManagementStorageProvider());\n        DefaultPackagesStorageConfiguration storageConfiguration = new DefaultPackagesStorageConfiguration();\n        storageConfiguration.setProperty(config.getProperties());\n        PackagesStorage storage = storageProvider.getStorage(storageConfiguration);\n        storage.initialize();\n        this.packagesManagement.initialize(storage);\n    }\n","sourceCodeStart":2228,"sourceCodeEnd":2264,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/PulsarService.java#L2228-L2264","documentation":"PulsarService.getPackagesManagement() returns the broker's package management service, which is only initialized when packages management is enabled in broker configuration. If the service was never initialized (packagesManagement == null), it throws UnsupportedOperationException. The broker does not ship a default implementation enabled out of the box, so the admin REST/Java API for packages cannot be used until it is configured.","triggerScenarios":"Calling any Packages API (e.g. REST endpoints under /admin/v3/packages, or getPackagesManagement() programmatically) on a broker where the package management service is not enabled/initialized; brokers built without the packages management provider configured.","commonSituations":"Deploying a standard broker without enabling packages management and then attempting to upload/download functions or packages via CLI (pulsar-admin packages) or admin client; using a broker version where the service is behind configuration and assuming it is on by default.","solutions":["Enable the package management service in broker.conf (set the packages management storage/service configuration, e.g. packagesManagementStorageProvider and related packages-management settings) and restart the broker.","If packages are not needed, stop using the packages APIs/functions package features and deploy functions via other supported mechanisms.","Upgrade to a broker version/config combination where package management initialization is supported via its provider.","Verify with a quick call that the service is enabled before invoking packages operations in tooling."],"exampleFix":"// before (broker.conf)\n# (packages management not configured)\n\n// after (broker.conf)\npackagesManagementStorageProvider=org.apache.pulsar.packages.management.storage.bookkeeper.impl.BookKeeperPackagesStorageProvider\npackagesStorageNamespace=public/packages","handlingStrategy":"validation","validationCode":"if (!brokerConfig.isPackageManagementEnabled()) {\n    throw new IllegalStateException(\"Enable package management in broker.conf before using packages APIs\");\n}","typeGuard":"boolean isPackagesManagementSupported(PulsarService pulsar) {\n    try { return pulsar.getPackagesManagement() != null; }\n    catch (UnsupportedOperationException e) { return false; }\n}","tryCatchPattern":"try {\n    PackagesManagement pm = pulsar.getPackagesManagement();\n    // use pm\n} catch (UnsupportedOperationException e) {\n    log.warn(\"Package management not enabled on this broker: {}\", e.getMessage());\n}","preventionTips":["Enable the packages management storage provider in broker.conf before using packages/functions-package APIs","Feature-detect once at startup and gate all packages operations behind that check","Keep pulsar-admin client and broker versions aligned on package-management support"],"tags":["broker","configuration","packages","unsupported-operation"],"backgroundTag":"feature-not-enabled","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"}