apache/pulsar · error · RuntimeException
Unknown componentType
Error message
Unknown componentType
What it means
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.
Source
Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/ComponentTypeUtils.java:33
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.pulsar.functions.utils;
import org.apache.pulsar.functions.proto.FunctionDetails;
public class ComponentTypeUtils {
public static String toString(FunctionDetails.ComponentType componentType) {
switch (componentType) {
case FUNCTION:
return "Function";
case SOURCE:
return "Source";
case SINK:
return "Sink";
default:
throw new RuntimeException("Unknown componentType " + componentType);
}
}
}
View on GitHub (pinned to 820761864e)
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
Example fix
// before
case SINK: return "Sink";
default: throw new RuntimeException("Unknown componentType " + componentType);
// after
case SINK: return "Sink";
case NEW_TYPE: return "NewType";
default: throw new RuntimeException("Unknown componentType " + componentType); Defensive patterns
Strategy: try-catch
Validate before calling
boolean knownType = componentType == ComponentType.FUNCTION
|| componentType == ComponentType.SOURCE
|| componentType == ComponentType.SINK;
if (!knownType) { /* handle/log before calling ComponentTypeUtils.toString */ } Type guard
static boolean isKnownComponentType(ComponentType t) {
return t == ComponentType.FUNCTION || t == ComponentType.SOURCE || t == ComponentType.SINK;
} Try / catch
try {
String name = ComponentTypeUtils.toString(componentType);
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Unknown componentType")) { /* upgrade module or map the new type */ }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unknown component type: %s
- Not support component type
- Unexpected monitoring class: ${monClass}
- Invalid key-shared mode: ${keySharedMode}
- Unknown resource type:
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/0216aa5cb4c70fa8.
Report an issue: GitHub.