apache/pulsar · error · RuntimeException

You must specify a name for the sink

Error message

You must specify a name for the sink

What it means

After applying tenant/namespace defaults, the sink command still requires an explicit sink name; if --name was not provided a RuntimeException is thrown, since every sink needs a unique identifying name.

Source

Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSinks.java:690

        protected String tenant;

        @Option(names = "--namespace", description = "The sink's namespace")
        protected String namespace;

        @Option(names = "--name", description = "The sink's name")
        protected String sinkName;

        @Override
        void processArguments() throws Exception {
            super.processArguments();
            if (tenant == null) {
                tenant = PUBLIC_TENANT;
            }
            if (namespace == null) {
                namespace = DEFAULT_NAMESPACE;
            }
            if (null == sinkName) {
                throw new RuntimeException(
                        "You must specify a name for the sink");
            }
        }
    }

    @Command(description = "Stops a Pulsar IO sink connector")
    protected class DeleteSink extends SinkCommand {

        @Override
        void runCmd() throws Exception {
            getAdmin().sinks().deleteSink(tenant, namespace, sinkName);
            print("Deleted successfully");
        }
    }

    @Command(description = "Gets the information about a Pulsar IO sink connector")
    protected class GetSink extends SinkCommand {

View on GitHub (pinned to 820761864e)

Solutions

  1. Add --name <sink-name> to the command
  2. If using --sink-config-file, add the "name" field to the config JSON
  3. Verify the flag name is `--name`, not a typo like `--sinkname`

Example fix

// before
pulsar-admin sinks create --archive ./s.nar --inputs i
// after
pulsar-admin sinks create --archive ./s.nar --inputs i --name my-sink
Defensive patterns

Strategy: validation

Validate before calling

if (!args.includes('--name') && !configHasField('name')) {
  throw new Error('Sink command requires --name');
}

Type guard

const hasName = (c) => typeof c?.name === 'string' && c.name.length > 0;

Try / catch

try {
  // run sinks command
} catch (e) {
  if (e.message.includes('must specify a name for the sink')) { /* add --name */ }
  throw e;
}

Prevention

When it happens

Trigger: Running `pulsar-admin sinks create/update/delete/restart` (any subcommand needing the name) without the `--name` flag and without a name in the provided config.

Common situations: Omitting --name assuming it is derived from the NAR filename or config; copy-pasted command truncated the name argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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