{"record":{"id":"7d1943988ffc52ed","repo":"apache/pulsar","slug":"unknown-component-type-componenttype","errorCode":null,"errorMessage":"Unknown component type: ${componentType}","messagePattern":"Unknown component type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/stats/ComponentStatsManager.java","lineNumber":69,"sourceCode":"\n    static {\n        EXCEPTION_METRICS_LABEL_NAMES = Arrays.copyOf(METRICS_LABEL_NAMES, METRICS_LABEL_NAMES.length + 1);\n        EXCEPTION_METRICS_LABEL_NAMES[METRICS_LABEL_NAMES.length] = \"error\";\n    }\n\n    public static ComponentStatsManager getStatsManager(FunctionCollectorRegistry collectorRegistry,\n                                  String[] metricsLabels,\n                                  ScheduledExecutorService scheduledExecutorService,\n                                  FunctionDetails.ComponentType componentType) {\n        switch (componentType) {\n            case FUNCTION:\n                return new FunctionStatsManager(collectorRegistry, metricsLabels, scheduledExecutorService);\n            case SOURCE:\n                return new SourceStatsManager(collectorRegistry, metricsLabels, scheduledExecutorService);\n            case SINK:\n                return new SinkStatsManager(collectorRegistry, metricsLabels, scheduledExecutorService);\n            default:\n                throw new RuntimeException(\"Unknown component type: \" + componentType);\n        }\n    }\n\n    public ComponentStatsManager(FunctionCollectorRegistry collectorRegistry,\n                                 String[] metricsLabels,\n                                 ScheduledExecutorService scheduledExecutorService) {\n\n        this.collectorRegistry = collectorRegistry;\n        this.metricsLabels = metricsLabels;\n\n        scheduledFuture = scheduledExecutorService.scheduleAtFixedRate(() -> {\n            try {\n                reset();\n            } catch (Exception e) {\n                log.error().exception(e).log(\"Failed to reset metrics for 1min window\");\n            }\n        }, 1, 1, TimeUnit.MINUTES);\n    }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/stats/ComponentStatsManager.java#L51-L87","documentation":"ComponentStatsManager.getStatsManager is a factory that dispatches on the function's component type (FUNCTION, SOURCE, SINK) and returns the matching stats manager. Thrown when the supplied FunctionConfig.Component type is not one of the three supported values, indicating a corrupt or incomplete config.","triggerScenarios":"Calling getStatsManager with a componentType outside the enum's FUNCTION/SOURCE/SINK cases (e.g. default branch hit because the enum value was deserialized to an unexpected constant).","commonSituations":"FunctionConfig built programmatically with an unknown/new component type; deserialization of a config file from a newer broker running older instance code; null or hand-edited function configuration.","solutions":["Check the FunctionConfig's componentType and set it to FUNCTION, SOURCE, or SINK.","Ensure the function config YAML/JSON is generated by matching client/worker versions, not hand-edited.","If a new component type was introduced, upgrade the function instance runtime to a version that supports it."],"exampleFix":"// before\nFunctionConfig cfg = ...; cfg.setComponent(null);\n// after\ncfg.setComponent(FunctionConfig.Component.FUNCTION); // or SOURCE / SINK","handlingStrategy":"validation","validationCode":"if (cfg.getComponent() != FunctionConfig.Component.FUNCTION\n    && cfg.getComponent() != FunctionConfig.Component.SOURCE\n    && cfg.getComponent() != FunctionConfig.Component.SINK) {\n  throw new IllegalStateException(\"componentType must be FUNCTION, SOURCE or SINK\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  statsManager = ComponentStatsManager.getStatsManager(cfg.getComponent(), ...);\n} catch (RuntimeException e) {\n  log.error(\"invalid component type {}\", cfg.getComponent(), e);\n}","preventionTips":["Always set componentType explicitly from a validated enum","Keep function instance runtime in sync with the client that generates configs"],"tags":["config","stats","pulsar-functions"],"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-14T05:17:10.506Z"}