apache/pulsar · error · ParameterException
Invalid schema type %s. Valid options are: avro, json
Error message
Invalid schema type %s. Valid options are: avro, json
What it means
CmdSchemas' 'set-schema' (upload) command accepts only 'avro' or 'json' as the --type value. The CLI lowercases the supplied type and, if it matches neither branch, throws this JCommander ParameterException before any schema is uploaded. It prevents invalid schema payload types from being sent to the broker.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java:182
File file = new File(jarFilePath);
ClassLoader cl = new URLClassLoader(new URL[]{ file.toURI().toURL() });
Class<?> cls = cl.loadClass(className);
PostSchemaPayload input = new PostSchemaPayload();
SchemaDefinition<Object> schemaDefinition =
SchemaDefinition.builder()
.withPojo(cls)
.withAlwaysAllowNull(alwaysAllowNull)
.build();
if (type.equalsIgnoreCase("avro")) {
input.setType("AVRO");
input.setSchema(SchemaExtractor.getAvroSchemaInfo(schemaDefinition));
} else if (type.equalsIgnoreCase("json")){
input.setType("JSON");
input.setSchema(SchemaExtractor.getJsonSchemaInfo(schemaDefinition));
} else {
throw new ParameterException("Invalid schema type " + type + ". Valid options are: avro, json");
}
input.setProperties(schemaDefinition.getProperties());
if (dryRun) {
System.out.println(topic);
System.out.println(MAPPER.writerWithDefaultPrettyPrinter()
.writeValueAsString(input));
} else {
getAdmin().schemas().createSchema(topic, input);
}
}
}
@Command(description = "Test schema compatibility")
private class TestCompatibility extends CliCommand {
@Parameters(description = "persistent://tenant/namespace/topic", arity = "1")
private String topicName;
@Option(names = { "-f", "--filename" }, description = "filename", required = true)View on GitHub (pinned to 820761864e)
Solutions
- Use --schema-type avro or --schema-type json only
- If you need another schema type, upload the schema via the REST API or client Schema API that supports it
- Check spelling: 'jason' -> 'json'
Example fix
// before pulsar-admin schemas upload --topic t --schema-type protobuf -f schema.pb // after pulsar-admin schemas upload --topic t --schema-type json -f schema.json
Defensive patterns
Strategy: validation
Validate before calling
const type = process.argv[process.argv.indexOf('--schema-type') + 1];
if (!['avro', 'json'].includes(type?.toLowerCase())) {
throw new Error(`Invalid schema type ${type}. Valid options are: avro, json`);
} Type guard
const isValidSchemaType = (t) => typeof t === 'string' && ['avro','json'].includes(t.toLowerCase());
Try / catch
try {
// run pulsar-admin schemas upload ...
} catch (e) {
if (e.message.includes('Invalid schema type')) { /* prompt for avro/json */ }
throw e;
} Prevention
- Only pass 'avro' or 'json' to the schemas upload CLI
- Check `pulsar-admin schemas upload --help` for supported types
- Use the REST/client schema API for other schema types
When it happens
Trigger: Running `pulsar-admin schemas upload --topic X --schema-type avro_or_json_other_values` with a type string that is not 'avro' or 'json' (case-insensitive), e.g. 'protobuf', 'string', 'keyvalue', or a misspelled 'jason'.
Common situations: Users assuming all Pulsar schema types (string, protobuf, avro, json) are valid for the CLI upload; typos in the type flag; copying examples from docs covering the Java Schema API which supports more types than this command.
Related errors
- Only one or neither of --version and --all-version can be sp
- Option --version must be greater than 0, but found %d
- schema type must be 'bytes' or 'auto_consume'
- Invalid schema type: ${valueSchema}
- schema type must be 'bytes' or 'auto_consume'
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/3d4d4eacf79793cb.
Report an issue: GitHub.