apache/pulsar · error · ParameterException

Only one or neither of --version and --all-version can be sp

Error message

Only one or neither of --version and --all-version can be specified.

What it means

`pulsar-admin schemas get` accepts either --version <n> to fetch a specific schema version or --all-version to fetch all versions, but not both. Passing both flags is contradictory and throws this ParameterException.

Source

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

        addCommand("compatibility", new TestCompatibility());
    }

    @Command(description = "Get the schema for a topic")
    private class GetSchema extends CliCommand {
        @Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
        private String topicName;

        @Option(names = {"-v", "--version"}, description = "version", required = false)
        private Long version;

        @Option(names = {"-a", "--all-version"}, description = "all version", required = false)
        private boolean all = false;

        @Override
        void run() throws Exception {
            String topic = validateTopicName(topicName);
            if (version != null && all) {
                throw new ParameterException("Only one or neither of --version and --all-version can be specified.");
            }
            if (version == null && !all) {
                System.out.println(getAdmin().schemas().getSchemaInfoWithVersion(topic));
            } else if (!all) {
                if (version < 0) {
                    throw new ParameterException("Option --version must be greater than 0, but found " + version);
                }
                System.out.println(getAdmin().schemas().getSchemaInfo(topic, version));
            } else {
                print(getAdmin().schemas().getAllSchemas(topic));
            }
        }
    }

    @Command(description = "Get the schema for a topic")
    private class GetSchemaMetadata extends CliCommand {
        @Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
        private String topicName;

View on GitHub (pinned to 820761864e)

Solutions

  1. Use only --version <n> for a single version
  2. Or use only --all-version for all versions
  3. Use neither flag to get the latest schema info with version

Example fix

// before
pulsar-admin schemas get --topic t --version 2 --all-version
// after
pulsar-admin schemas get --topic t --version 2
Defensive patterns

Strategy: validation

Validate before calling

if (version != null && allVersion) {
    throw new IllegalArgumentException("--version and --all-version are mutually exclusive");
}

Try / catch

try {
    SchemaInfo info = admin.schemas().getSchemaInfo(topic);
} catch (org.apache.pulsar.client.admin.PulsarAdminException e) {
    // handle bad flag combination
}

Prevention

When it happens

Trigger: Running `pulsar-admin schemas get --version 3 --all-version <topic>` or with both flags set in a script.

Common situations: Script variables for both flags populated by mistake; combining two example commands; alias wrapping both options.

Related errors


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