{"record":{"id":"64c1e4e109509f6d","repo":"apache/pulsar","slug":"invalid-schema-type-valueschema","errorCode":null,"errorMessage":"Invalid schema type: ${valueSchema}","messagePattern":"Invalid schema type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java","lineNumber":369,"sourceCode":"                return new ValueSchema(Schema.bytes(), null);\n            case \"string\":\n                return new ValueSchema(Schema.autoProduceBytesOf(Schema.string()), null);\n            default:\n                if (valueSchema.startsWith(\"avro:\")) {\n                    String def = valueSchema.substring(5);\n                    org.apache.avro.Schema avroNative = new org.apache.avro.Schema.Parser().parse(def);\n                    Schema<?> generic = Schema.generic(\n                            SchemaInfo.of(\"client\", SchemaType.AVRO,\n                                    def.getBytes(StandardCharsets.UTF_8), null));\n                    return new ValueSchema(Schema.autoProduceBytesOf(generic), avroNative);\n                } else if (valueSchema.startsWith(\"json:\")) {\n                    String def = valueSchema.substring(5);\n                    Schema<?> generic = Schema.generic(\n                            SchemaInfo.of(\"client\", SchemaType.JSON,\n                                    def.getBytes(StandardCharsets.UTF_8), null));\n                    return new ValueSchema(Schema.autoProduceBytesOf(generic), null);\n                }\n                throw new IllegalArgumentException(\"Invalid schema type: \" + valueSchema);\n        }\n    }\n\n    private static ProducerEncryptionPolicy buildEncryptionPolicy(String keyName, String keyUri) {\n        return ProducerEncryptionPolicy.builder()\n                .publicKeyProvider(org.apache.pulsar.client.api.v5.auth.PemFileKeyProvider.builder()\n                        .publicKey(keyName, fileUriToPath(keyUri))\n                        .build())\n                .keyName(keyName)\n                .build();\n    }\n\n    @VisibleForTesting\n    public String getWebSocketProduceUri(String topic) {\n        String serviceURLWithoutTrailingSlash = serviceURL.substring(0,\n                serviceURL.endsWith(\"/\") ? serviceURL.length() - 1 : serviceURL.length());\n\n        TopicName topicName = TopicName.get(topic);","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java#L351-L387","documentation":"CmdProduce.buildValueSchema maps the -vs/--value-schema argument to a Schema. Only a small set of prefixes/types is recognized (bytes, string, avro:, json:, etc.); anything else falls to the default branch and throws IllegalArgumentException naming the offending value.","triggerScenarios":"Running `pulsar-client produce ... -vs <value>` where <value> is not one of the supported types, e.g. -vs int8, -vs protobuf:, a typo like -vs bytes(, or an unsupported prefix like -vs keyvalue:.","commonSituations":"Copying schema strings from a full pulsar-client (which supports many SchemaType values) into this V5 CLI; misspelling avro/json; expecting primitive schema types like int32 to work.","solutions":["Use a supported schema type: -vs bytes, -vs string, -vs 'avro:<schema definition>', or -vs 'json:<schema definition>'.","Fix typos and check the exact prefix format (avro:/json: followed by the schema definition string).","Omit -vs entirely to use the default schema if you just need raw bytes.","Verify against this CLI's help (`pulsar-client produce --help`) rather than generic Pulsar docs."],"exampleFix":"// before\npulsar-client produce t -m '42' -vs int32\n// after\npulsar-client produce t -m '42' -vs 'json:{\"type\":\"int\"}'   // or -vs bytes/string/avro:<def>","handlingStrategy":"validation","validationCode":"// bash: allow only supported -vs values\ncase \"$VS\" in ''|bytes|string|avro:*|json:*) ;; *) echo \"invalid schema type: $VS\"; exit 1;; esac","typeGuard":"function isValidValueSchema(vs) { return vs == null || ['bytes','string'].includes(vs) || /^(avro|json):/.test(vs); }","tryCatchPattern":"try { produce(vs); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Invalid schema type\")) { /* correct -vs and retry */ } else throw e; }","preventionTips":["Restrict -vs to bytes, string, avro:<def>, or json:<def>.","Don't copy schema type names from full-client docs into this V5 CLI.","Validate the schema string in scripts before invoking the CLI."],"tags":["cli","schema","validation","avro","json"],"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"}