apache/pulsar · error · IllegalArgumentException
Function name cannot be null
Error message
Function name cannot be null
What it means
doCommonChecks requires a function name; together with tenant and namespace it forms the unique function identity (tenant/namespace/name). A null or empty name makes the function unaddressable, so validation throws this IllegalArgumentException immediately.
Source
Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionConfigUtils.java:797
private static void verifyNoTopicClash(Collection<String> inputTopics, String outputTopic)
throws IllegalArgumentException {
if (inputTopics.contains(outputTopic)) {
throw new IllegalArgumentException(
String.format(
"Output topic %s is also being used as an input topic (topics must be one or the other)",
outputTopic));
}
}
public static void doCommonChecks(FunctionConfig functionConfig) {
if (isEmpty(functionConfig.getTenant())) {
throw new IllegalArgumentException("Function tenant cannot be null");
}
if (isEmpty(functionConfig.getNamespace())) {
throw new IllegalArgumentException("Function namespace cannot be null");
}
if (isEmpty(functionConfig.getName())) {
throw new IllegalArgumentException("Function name cannot be null");
}
// go doesn't need className. Java className is done in doJavaChecks.
if (functionConfig.getRuntime() == FunctionConfig.Runtime.PYTHON) {
if (isEmpty(functionConfig.getClassName())) {
throw new IllegalArgumentException("Function classname cannot be null");
}
}
Collection<String> allInputTopics = collectAllInputTopics(functionConfig);
if (allInputTopics.isEmpty()) {
throw new IllegalArgumentException("No input topic(s) specified for the function");
}
for (String topic : allInputTopics) {
if (!TopicName.isValid(topic)) {
throw new IllegalArgumentException(String.format("Input topic %s is invalid", topic));
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Set a non-empty name: functionConfig.setName("my-function").
- Add the 'name' key to the YAML/JSON config file.
- Check code paths that build configs dynamically to ensure the name variable is assigned before validation.
- Remember the name must be valid within the tenant/namespace and not collide with an existing function.
Example fix
// before
config.setTenant("public");
config.setNamespace("default");
// after
config.setTenant("public");
config.setNamespace("default");
config.setName("my-function"); Defensive patterns
Strategy: validation
Validate before calling
if (config == null || config.getName() == null || config.getName().trim().isEmpty()) {
throw new IllegalArgumentException("FunctionConfig.name must be set before submission");
} Type guard
static boolean hasName(FunctionConfig c) {
return c != null && c.getName() != null && !c.getName().trim().isEmpty();
} Try / catch
try {
FunctionConfigUtils.validateNonJavaFunction(functionConfig, null);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("name")) {
throw new IllegalStateException("Function name is required: pass --name or set 'name' in the config", e);
}
throw e;
} Prevention
- Derive the function name from a single required variable so it cannot be silently null.
- In config generators, assert name is non-empty before writing the YAML/JSON.
- Keep tenant/namespace/name assigned together in one factory method.
- Check for name collisions within the tenant/namespace before create.
When it happens
Trigger: Creating or updating a function with a FunctionConfig whose getName() is null/empty — via validateJavaFunction/validateNonJavaFunction, the functions worker REST API, or pulsar-admin functions create without --name or with a config file lacking the 'name' key.
Common situations: Programmatic config building where name was overlooked; YAML/JSON templates missing 'name'; dynamic generation of configs in loops where the name variable was never assigned; refactors renaming the setter that left the call site behind.
Understand the failure class
Background: "X is required", "field cannot be empty", error-the-field-is-required: missing required-field validation errors, explained — this error's family across 39 libraries.
Related errors
- When Guarantees == ATMOST_ONCE, autoAck must be equal to tru
- Function tenant cannot be null
- Function namespace cannot be null
- there are redundant configure for listener `${listenerName}`
- must not specify `${hostPort}` to different listener.
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/a9342d2c92c14515.
Report an issue: GitHub.