apache/pulsar · error · RuntimeException
Unknown component type: ${componentType}
Error message
Unknown component type: ${componentType} What it means
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.
Source
Thrown at pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/stats/ComponentStatsManager.java:69
static {
EXCEPTION_METRICS_LABEL_NAMES = Arrays.copyOf(METRICS_LABEL_NAMES, METRICS_LABEL_NAMES.length + 1);
EXCEPTION_METRICS_LABEL_NAMES[METRICS_LABEL_NAMES.length] = "error";
}
public static ComponentStatsManager getStatsManager(FunctionCollectorRegistry collectorRegistry,
String[] metricsLabels,
ScheduledExecutorService scheduledExecutorService,
FunctionDetails.ComponentType componentType) {
switch (componentType) {
case FUNCTION:
return new FunctionStatsManager(collectorRegistry, metricsLabels, scheduledExecutorService);
case SOURCE:
return new SourceStatsManager(collectorRegistry, metricsLabels, scheduledExecutorService);
case SINK:
return new SinkStatsManager(collectorRegistry, metricsLabels, scheduledExecutorService);
default:
throw new RuntimeException("Unknown component type: " + componentType);
}
}
public ComponentStatsManager(FunctionCollectorRegistry collectorRegistry,
String[] metricsLabels,
ScheduledExecutorService scheduledExecutorService) {
this.collectorRegistry = collectorRegistry;
this.metricsLabels = metricsLabels;
scheduledFuture = scheduledExecutorService.scheduleAtFixedRate(() -> {
try {
reset();
} catch (Exception e) {
log.error().exception(e).log("Failed to reset metrics for 1min window");
}
}, 1, 1, TimeUnit.MINUTES);
}View on GitHub (pinned to 820761864e)
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.
Example fix
// before FunctionConfig cfg = ...; cfg.setComponent(null); // after cfg.setComponent(FunctionConfig.Component.FUNCTION); // or SOURCE / SINK
Defensive patterns
Strategy: validation
Validate before calling
if (cfg.getComponent() != FunctionConfig.Component.FUNCTION
&& cfg.getComponent() != FunctionConfig.Component.SOURCE
&& cfg.getComponent() != FunctionConfig.Component.SINK) {
throw new IllegalStateException("componentType must be FUNCTION, SOURCE or SINK");
} Try / catch
try {
statsManager = ComponentStatsManager.getStatsManager(cfg.getComponent(), ...);
} catch (RuntimeException e) {
log.error("invalid component type {}", cfg.getComponent(), e);
} Prevention
- Always set componentType explicitly from a validated enum
- Keep function instance runtime in sync with the client that generates configs
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Config class not found: %s
- Unsupported schema type${type}
- Batch Configs cannot be found
- Malformed configuration parameter: earlyTokenRefreshPercent
- Unsupported media type or encoding format: ${contentType}
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/7d1943988ffc52ed.
Report an issue: GitHub.