{"record":{"id":"0216aa5cb4c70fa8","repo":"apache/pulsar","slug":"unknown-componenttype","errorCode":null,"errorMessage":"Unknown componentType ","messagePattern":"Unknown componentType ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/ComponentTypeUtils.java","lineNumber":33,"sourceCode":" * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\npackage org.apache.pulsar.functions.utils;\n\nimport org.apache.pulsar.functions.proto.FunctionDetails;\n\npublic class ComponentTypeUtils {\n    public static String toString(FunctionDetails.ComponentType componentType) {\n        switch (componentType) {\n            case FUNCTION:\n                return \"Function\";\n            case SOURCE:\n                return \"Source\";\n            case SINK:\n                return \"Sink\";\n            default:\n                throw new RuntimeException(\"Unknown componentType \" + componentType);\n        }\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":37,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/ComponentTypeUtils.java#L15-L37","documentation":"ComponentTypeUtils.toString maps known ComponentType enum values (FUNCTION, SOURCE, SINK) to display strings and throws a RuntimeException for any other value. This acts as an exhaustive-switch guard: if a new ComponentType is added to the enum without updating this utility, runtime code that renders the type hits this error.","triggerScenarios":"Calling ComponentTypeUtils.toString(componentType) with a ComponentType value not handled by the switch — practically, a newly added enum constant (e.g. a future component kind) or a null/default-uninitialized value passed as componentType.","commonSituations":"upgrading Pulsar where new ComponentType constants exist but older ConnectorUtils/toString code is on the classpath; custom code constructing ComponentType values directly; passing null into the utility.","solutions":["Upgrade the pulsar-functions-utils module so ComponentTypeUtils handles the new ComponentType constant","Add a case for the new enum value to the switch in ComponentTypeUtils.toString","Check for null before calling toString and map it to a valid ComponentType explicitly"],"exampleFix":"// before\ncase SINK: return \"Sink\";\ndefault: throw new RuntimeException(\"Unknown componentType \" + componentType);\n// after\ncase SINK: return \"Sink\";\ncase NEW_TYPE: return \"NewType\";\ndefault: throw new RuntimeException(\"Unknown componentType \" + componentType);","handlingStrategy":"try-catch","validationCode":"boolean knownType = componentType == ComponentType.FUNCTION\n        || componentType == ComponentType.SOURCE\n        || componentType == ComponentType.SINK;\nif (!knownType) { /* handle/log before calling ComponentTypeUtils.toString */ }","typeGuard":"static boolean isKnownComponentType(ComponentType t) {\n    return t == ComponentType.FUNCTION || t == ComponentType.SOURCE || t == ComponentType.SINK;\n}","tryCatchPattern":"try {\n    String name = ComponentTypeUtils.toString(componentType);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Unknown componentType\")) { /* upgrade module or map the new type */ }\n}","preventionTips":["Keep pulsar-functions-utils at the same version as the rest of Pulsar modules (no mixed jars)","Add a case for any new ComponentType constant in ComponentTypeUtils","Null-check componentType before calling the utility"],"tags":["enum","pulsar-functions","version-mismatch"],"backgroundTag":"unknown-enum-value","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"}