{"record":{"id":"97d5d11b853bb0eb","repo":"apache/pulsar","slug":"invalid-package-domain-value","errorCode":null,"errorMessage":"Invalid package domain: '${value}'","messagePattern":"Invalid package domain: '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-admin-api/src/main/java/org/apache/pulsar/packages/management/core/common/PackageType.java","lineNumber":43,"sourceCode":"    FUNCTION(\"function\"), SINK(\"sink\"), SOURCE(\"source\");\n\n    private final String value;\n\n    PackageType(String value) {\n        this.value = value;\n    }\n\n    public String value() {\n        return this.value;\n    }\n\n    public static PackageType getEnum(String value) {\n        for (PackageType e : values()) {\n            if (e.value.equalsIgnoreCase(value)) {\n                return e;\n            }\n        }\n        throw new IllegalArgumentException(\"Invalid package domain: '\" + value + \"'\");\n    }\n\n    @Override\n    public String toString() {\n        return this.value;\n    }\n}\n","sourceCodeStart":25,"sourceCodeEnd":51,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-admin-api/src/main/java/org/apache/pulsar/packages/management/core/common/PackageType.java#L25-L51","documentation":"PackageType.getEnum converts a string (e.g. from a package URL like 'function://') into a PackageType enum by case-insensitive match against known values. If no enum constant matches, it throws IllegalArgumentException naming the unrecognized domain. Pulsar packages are identified by a domain prefix, so an unknown prefix means the package URL is malformed or from a newer/older Pulsar version.","triggerScenarios":"Calling PackageType.getEnum(value) with a string that is not one of the defined package types (function, sink, source, package), e.g. parsing a package name whose URL prefix is 'foo://', empty, or misspelled ('Function' is OK, 'fn://' is not).","commonSituations":"Typo in a packages:// or function:// URL passed to the Packages admin API; using a package domain introduced in a newer Pulsar version against an older broker/client; hand-constructed package names missing the 'domain://' prefix.","solutions":["Fix the package URL domain prefix to one of the supported values (function, sink, source, package).","Check the string for typos, extra whitespace, or missing '://' prefix before calling getEnum.","Upgrade client/broker so both sides know the same PackageType values.","Catch IllegalArgumentException around getEnum and validate the domain before use."],"exampleFix":"// before\nPackageType type = PackageType.getEnum(\"functions\");\n// after\nPackageType type = PackageType.getEnum(\"function\");","handlingStrategy":"try-catch","validationCode":"boolean valid = Arrays.stream(PackageType.values())\n    .anyMatch(t -> t.toString().equalsIgnoreCase(value));\nif (!valid) {\n    throw new IllegalArgumentException(\"Unknown package domain: \" + value);\n}","typeGuard":null,"tryCatchPattern":"try {\n    PackageType type = PackageType.getEnum(value);\n} catch (IllegalArgumentException e) {\n    log.error(\"Unsupported package type in URL: {}\", value);\n    return;\n}","preventionTips":["Always build package names from the PackageType enum's toString(), never raw strings.","Validate the 'domain://' prefix of package URLs before parsing.","Keep client and broker versions aligned on supported package types."],"tags":["pulsar","packages","enum","validation"],"backgroundTag":"invalid-enum-value","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"}