apache/pulsar · error · IllegalArgumentException

Sink name cannot be null

Error message

Sink name cannot be null

What it means

Config validation entry point in SinkConfigUtils.validateAndExtractDetails: the sink configuration is missing a required field — the excerpt shows the first check firing on an empty tenant (with sink name null-ness among the guards) — so the sink cannot be registered; the incomplete SinkConfig field is the faulty input.

Source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SinkConfigUtils.java:425

            sinkConfig.setTransformFunctionConfig(functionDetails.getUserConfig());
        }


        return sinkConfig;
    }

    public static ExtractedSinkDetails validateAndExtractDetails(SinkConfig sinkConfig,
                                                                 ValidatableFunctionPackage sinkFunction,
                                                                 ValidatableFunctionPackage transformFunction,
                                                                 boolean validateConnectorConfig) {
        if (isEmpty(sinkConfig.getTenant())) {
            throw new IllegalArgumentException("Sink tenant cannot be null");
        }
        if (isEmpty(sinkConfig.getNamespace())) {
            throw new IllegalArgumentException("Sink namespace cannot be null");
        }
        if (isEmpty(sinkConfig.getName())) {
            throw new IllegalArgumentException("Sink name cannot be null");
        }

        // make we sure we have one source of input
        Collection<String> allInputs = collectAllInputTopics(sinkConfig);
        if (allInputs.isEmpty()) {
            throw new IllegalArgumentException("Must specify at least one topic of input via topicToSerdeClassName, "
                    + "topicsPattern, topicToSchemaType or inputSpecs");
        }
        for (String topic : allInputs) {
            if (!TopicName.isValid(topic)) {
                throw new IllegalArgumentException(String.format("Input topic %s is invalid", topic));
            }
        }
        if (!isEmpty(sinkConfig.getLogTopic())) {
            if (!TopicName.isValid(sinkConfig.getLogTopic())) {
                throw new IllegalArgumentException(
                        String.format("LogTopic topic %s is invalid", sinkConfig.getLogTopic()));
            }

View on GitHub (pinned to 820761864e)

Solutions

  1. Set the sink name in the config

Example fix

// before
SinkConfig cfg = new SinkConfig();
cfg.setTenant("public");
cfg.setNamespace("default");
// after
SinkConfig cfg = new SinkConfig();
cfg.setTenant("public");
cfg.setNamespace("default");
cfg.setName("elastic-sink");
Defensive patterns

Strategy: validation

Validate before calling

if (sinkConfig.getName() == null || sinkConfig.getName().isEmpty()) {
    throw new IllegalArgumentException("sinkConfig.name must be set before submission");
}

Type guard

static boolean hasName(SinkConfig cfg) {
    return cfg != null && cfg.getName() != null && !cfg.getName().trim().isEmpty();
}

Try / catch

try {
    SinkConfigUtils.validateAndExtractDetails(cfg, sinkPkg, transformPkg, true);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("name")) {
        log.error("Sink config missing name: fix config and retry", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Creating a sink where SinkConfig.setName() was never invoked, e.g. pulsar-admin sink create without --name and no name in the config file.

Common situations: CLI usage relying on the archive to provide a name; generated configs omitting 'name'; test harnesses building minimal configs.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/34b26f37d0eb462d. Report an issue: GitHub.