{"record":{"id":"7d3a0a16b0558d1a","repo":"apache/pulsar","slug":"unknown-component-type-s","errorCode":null,"errorMessage":"Unknown component type: %s","messagePattern":"Unknown component type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java","lineNumber":209,"sourceCode":"                    }.getType());\n        } else {\n            secretsMap = new HashMap<>();\n        }\n\n        this.metricsLabels = metricsLabels;\n        String prefix;\n        switch (componentType) {\n            case FUNCTION:\n                prefix = FunctionStatsManager.PULSAR_FUNCTION_METRICS_PREFIX;\n                break;\n            case SINK:\n                prefix = SinkStatsManager.PULSAR_SINK_METRICS_PREFIX;\n                break;\n            case SOURCE:\n                prefix = SourceStatsManager.PULSAR_SOURCE_METRICS_PREFIX;\n                break;\n            default:\n                throw new RuntimeException(\"Unknown component type: \" + componentType);\n        }\n        this.userMetricsSummary = collectorRegistry.registerIfNotExist(\n                prefix + ComponentStatsManager.USER_METRIC_PREFIX,\n                Summary.build()\n                        .name(prefix + ComponentStatsManager.USER_METRIC_PREFIX)\n                        .help(\"User defined metric.\")\n                        .labelNames(userMetricsLabelNames)\n                        .quantile(0.5, 0.01)\n                        .quantile(0.9, 0.01)\n                        .quantile(0.99, 0.01)\n                        .quantile(0.999, 0.01)\n                        .create());\n        this.componentType = componentType;\n        this.stateManager = stateManager;\n        this.defaultStateStore = (DefaultStateStore) stateManager.getStore(\n                config.getFunctionDetails().getTenant(),\n                config.getFunctionDetails().getNamespace(),\n                config.getFunctionDetails().getName()","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/ContextImpl.java#L191-L227","documentation":"ContextImpl registers user metrics with a metrics-name prefix that depends on the component type (FUNCTION, SOURCE, SINK). The switch in the metrics initialization has cases for SOURCE and SINK only; any other component type reaching this code hits the default branch and throws a RuntimeException, because there is no metrics prefix defined for it.","triggerScenarios":"An instance is created with a ComponentType that is neither SOURCE nor SINK (i.e. FUNCTION) yet the user-metrics registration path runs — a framework bug/misconfiguration where FunctionStatsManager prefix handling is bypassed, or componentType enum is null/unexpected.","commonSituations":"Deploying a function where the instance config's componentType was mis-set (e.g. left unset/null) by a custom runner; running a Function instance through a code path intended only for connectors; version mismatches between broker and function instance packages.","solutions":["Verify the instance config (instances.yml / function details) sets componentType correctly (FUNCTION for functions, SOURCE/SINK for connectors).","If you hit this for a plain Function, it is a framework bug — check the Pulsar version and upgrade to a release where the FUNCTION case is handled.","Inspect how the instance was launched (KubernetesRuntime/JavaInstanceMain args) to ensure the correct component type is passed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (componentType != ComponentType.SOURCE && componentType != ComponentType.SINK) {\n    throw new IllegalArgumentException(\"Metrics prefix only defined for SOURCE/SINK, got: \" + componentType);\n}","typeGuard":null,"tryCatchPattern":"try { /* init context */ } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Unknown component type\")) { log.error(\"instance componentType misconfigured\"); throw e; } }","preventionTips":["Ensure instance config sets componentType to FUNCTION/SOURCE/SINK explicitly","Keep broker and function-instance package versions in sync","Validate function config before deployment (pulsar-admin functions create)"],"tags":["pulsar-functions","metrics","configuration","enum"],"backgroundTag":"unknown-component-type","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"}