{"record":{"id":"3d4d4eacf79793cb","repo":"apache/pulsar","slug":"invalid-schema-type-s-valid-options-are-avro-j","errorCode":null,"errorMessage":"Invalid schema type %s. Valid options are: avro, json","messagePattern":"Invalid schema type (.+?)\\. Valid options are: avro, json","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java","lineNumber":182,"sourceCode":"\n            File file  = new File(jarFilePath);\n            ClassLoader cl = new URLClassLoader(new URL[]{ file.toURI().toURL() });\n            Class<?> cls = cl.loadClass(className);\n\n            PostSchemaPayload input = new PostSchemaPayload();\n            SchemaDefinition<Object> schemaDefinition =\n                    SchemaDefinition.builder()\n                                    .withPojo(cls)\n                                    .withAlwaysAllowNull(alwaysAllowNull)\n                                    .build();\n            if (type.equalsIgnoreCase(\"avro\")) {\n                input.setType(\"AVRO\");\n                input.setSchema(SchemaExtractor.getAvroSchemaInfo(schemaDefinition));\n            } else if (type.equalsIgnoreCase(\"json\")){\n                input.setType(\"JSON\");\n                input.setSchema(SchemaExtractor.getJsonSchemaInfo(schemaDefinition));\n            } else {\n                throw new ParameterException(\"Invalid schema type \" + type + \". Valid options are: avro, json\");\n            }\n            input.setProperties(schemaDefinition.getProperties());\n            if (dryRun) {\n                System.out.println(topic);\n                System.out.println(MAPPER.writerWithDefaultPrettyPrinter()\n                                         .writeValueAsString(input));\n            } else {\n                getAdmin().schemas().createSchema(topic, input);\n            }\n        }\n    }\n\n    @Command(description = \"Test schema compatibility\")\n    private class TestCompatibility extends CliCommand {\n        @Parameters(description = \"persistent://tenant/namespace/topic\", arity = \"1\")\n        private String topicName;\n\n        @Option(names = { \"-f\", \"--filename\" }, description = \"filename\", required = true)","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSchemas.java#L164-L200","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","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'"],"exampleFix":"// before\npulsar-admin schemas upload --topic t --schema-type protobuf -f schema.pb\n// after\npulsar-admin schemas upload --topic t --schema-type json -f schema.json","handlingStrategy":"validation","validationCode":"const type = process.argv[process.argv.indexOf('--schema-type') + 1];\nif (!['avro', 'json'].includes(type?.toLowerCase())) {\n  throw new Error(`Invalid schema type ${type}. Valid options are: avro, json`);\n}","typeGuard":"const isValidSchemaType = (t) => typeof t === 'string' && ['avro','json'].includes(t.toLowerCase());","tryCatchPattern":"try {\n  // run pulsar-admin schemas upload ...\n} catch (e) {\n  if (e.message.includes('Invalid schema type')) { /* prompt for avro/json */ }\n  throw e;\n}","preventionTips":["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"],"tags":["cli","schema","validation"],"backgroundTag":"invalid-schema-type","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}