{"record":{"id":"ea1153b2f5b05d74","repo":"apache/pulsar","slug":"keyvalue-schemas-key-value-encoding-type-are-n","errorCode":null,"errorMessage":"KeyValue schemas (--key-value-encoding-type) are not supported by this version of pulsar-client; produce with a plain value schema (-vs bytes|string|avro:<def>|json:<def>) instead.","messagePattern":"KeyValue schemas \\(--key-value-encoding-type\\) are not supported by this version of pulsar-client; produce with a plain value schema \\(-vs bytes\\|string\\|avro:<def>\\|json:<def>\\) instead\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java","lineNumber":264,"sourceCode":"        if (this.numTimesProduce <= 0) {\n            throw new CommandLine.ParameterException(commandSpec.commandLine(),\n                    \"Number of times need to be positive number.\");\n        }\n\n        if (messages.size() > 0) {\n            messages = messages.stream().map(str -> str.split(separator)).flatMap(Stream::of).toList();\n        }\n\n        if (messages.size() == 0 && messageFileNames.size() == 0) {\n            throw new CommandLine.ParameterException(commandSpec.commandLine(),\n                    \"Please supply message content with either --messages or --files\");\n        }\n\n        if (keyValueEncodingType == null) {\n            keyValueEncodingType = KEY_VALUE_ENCODING_TYPE_NOT_SET;\n        } else if (!KEY_VALUE_ENCODING_TYPE_NOT_SET.equals(keyValueEncodingType)) {\n            // KeyValue schemas are not yet supported by the V5-based pulsar-client.\n            throw new IllegalArgumentException(\"KeyValue schemas (--key-value-encoding-type) are not \"\n                    + \"supported by this version of pulsar-client; produce with a plain value schema \"\n                    + \"(-vs bytes|string|avro:<def>|json:<def>) instead.\");\n        }\n\n        int totalMessages = (messages.size() + messageFileNames.size()) * numTimesProduce;\n        if (totalMessages > MAX_MESSAGES) {\n            String msg = \"Attempting to send \" + totalMessages + \" messages. Please do not send more than \"\n                    + MAX_MESSAGES + \" messages\";\n            throw new IllegalArgumentException(msg);\n        }\n\n        if (this.serviceURL.startsWith(\"ws\")) {\n            return publishToWebSocket(topic);\n        } else {\n            return publish(topic);\n        }\n    }\n","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdProduce.java#L246-L282","documentation":"This V5-based pulsar-client CLI does not implement KeyValue schema support, so if the user passes a non-default --key-value-encoding-type the command fails fast with IllegalArgumentException rather than producing incorrectly encoded messages. Use a plain value schema instead.","triggerScenarios":"Running CmdProduce.run() with --key-value-encoding-type set to anything other than the not-set sentinel value (e.g. INLINE or SEPARATED).","commonSituations":"Porting old produce scripts that used KeyValue topics; users who think they must set an encoding type for JSON/Avro; copy-pasted commands from docs targeting a full (non-V5) client.","solutions":["Remove --key-value-encoding-type from the command line.","Produce with a plain value schema via -vs, e.g. -vs bytes, -vs string, -vs 'avro:<schema-def>' or -vs 'json:<schema-def>'.","If you need KeyValue semantics, use a full pulsar-client distribution/version that supports KeyValue schemas instead of this V5-based CLI."],"exampleFix":"// before\npulsar-client produce t -m '{\"a\":1}' --key-value-encoding-type INLINE\n// after\npulsar-client produce t -m '{\"a\":1}' -vs 'json:{\"type\":\"record\",\"name\":\"R\",\"fields\":[{\"name\":\"a\",\"type\":\"int\"}]}'","handlingStrategy":"validation","validationCode":"// reject the unsupported option before running\nif [[ \"$*\" == *--key-value-encoding-type* ]]; then echo 'KeyValue not supported; use -vs bytes|string|avro:|json:'; exit 1; fi","typeGuard":null,"tryCatchPattern":"try { produce(args); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"KeyValue schemas\")) { /* drop the option and retry with -vs ... */ } else throw e; }","preventionTips":["Never pass --key-value-encoding-type with this V5-based CLI.","Use -vs with a plain value schema for JSON/Avro payloads.","Check `pulsar-client produce --help` for supported options before porting old scripts."],"tags":["cli","schema","unsupported-feature","keyvalue"],"backgroundTag":"unsupported-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"}