{"record":{"id":"43b83f0c4a38fa9f","repo":"apache/pulsar","slug":"schema-type-must-be-bytes-or-auto-consume","errorCode":null,"errorMessage":"schema type must be 'bytes' or 'auto_consume'","messagePattern":"schema type must be 'bytes' or 'auto_consume'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdConsume.java","lineNumber":188,"sourceCode":"\n        if (this.serviceURL.startsWith(\"ws\")) {\n            return consumeFromWebSocket(topic);\n        } else {\n            return consume(topic);\n        }\n    }\n\n    private int consume(String topic) {\n        int numMessagesConsumed = 0;\n        int returnCode = 0;\n\n        final Schema<?> schema;\n        if (\"auto_consume\".equals(schemaType)) {\n            schema = Schema.autoConsume();\n        } else if (\"bytes\".equals(schemaType)) {\n            schema = Schema.bytes();\n        } else {\n            throw new IllegalArgumentException(\"schema type must be 'bytes' or 'auto_consume'\");\n        }\n        if (!poolMessages) {\n            LOG.info(\"--pool-messages has no effect on this version of pulsar-client.\");\n        }\n        if (subscriptionMode == SubscriptionMode.NonDurable) {\n            LOG.warn(\"--subscription-mode NonDurable is not supported by this version of pulsar-client; \"\n                    + \"a durable subscription is used instead.\");\n        }\n        if (subscriptionType == SubscriptionType.Exclusive || subscriptionType == SubscriptionType.Failover) {\n            // The V5 StreamConsumer (ordered, single-reader) requires a scalable-topic subscription\n            // controller, which regular topics do not have; only the QueueConsumer works against\n            // both regular and scalable topics. So all subscription types use a QueueConsumer here\n            // and Exclusive/Failover get work-queue (Shared-style) semantics rather than ordered.\n            LOG.warn(\"--subscription-type {} : this version of pulsar-client consumes via a work-queue \"\n                    + \"(Shared-style) subscription; exclusive/failover ordering is not preserved.\",\n                    subscriptionType);\n        }\n        if (maxPendingChunkedMessage > 0 || autoAckOldestChunkedMessageOnQueueFull) {","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdConsume.java#L170-L206","documentation":"CmdConsume.consume builds the consumer Schema from the --schema-type argument and only accepts 'auto_consume' (Schema.autoConsume) or 'bytes' (Schema.bytes). Any other string throws IllegalArgumentException before the consumer is created, because this CLI build cannot materialize other schema types.","triggerScenarios":"Passing --schema-type json, avro, string, etc. to the consume command; or an misspelled variant like 'auto-consume'.","commonSituations":"Copying --schema-type from producer docs where json/avro are valid there; expecting the CLI to deserialize AVRO payloads natively; older scripts written against a CLI build that accepted more types.","solutions":["Use --schema-type auto_consume to decode using the topic's schema information","Use --schema-type bytes to receive raw payload bytes","Exact spelling matters: 'bytes' or 'auto_consume', case-sensitive equals check"],"exampleFix":"// before\n--schema-type json\n// after\n--schema-type auto_consume","handlingStrategy":"validation","validationCode":"if (!(\"bytes\".equals(schemaType) || \"auto_consume\".equals(schemaType)))\n    throw new IllegalArgumentException(\"--schema-type must be 'bytes' or 'auto_consume', got: \" + schemaType);","typeGuard":"static boolean isSupportedConsumeSchemaType(String s) {\n    return \"bytes\".equals(s) || \"auto_consume\".equals(s);\n}","tryCatchPattern":"try {\n    return consume(topic, schemaType);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"schema type must be\")) {\n        LOG.warn(\"Unsupported --schema-type '{}'; falling back to auto_consume\", schemaType);\n        return consume(topic, \"auto_consume\");\n    } else { throw e; }\n}","preventionTips":["Only use the two documented values: bytes, auto_consume (exact, case-sensitive spelling)","Don't copy --schema-type values from producer-side docs (json/avro are producer-side options)","Pin CLI usage in wrappers that whitelist the allowed values","Check the CLI version's supported types before upgrading scripts"],"tags":["cli","schema","validation","arguments"],"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-14T05:17:10.506Z"}