{"record":{"id":"4b14188a94d182db","repo":"apache/pulsar","slug":"schema-type-must-be-bytes-or-auto-consume-4b1418","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/CmdRead.java","lineNumber":148,"sourceCode":"\n        if (this.serviceURL.startsWith(\"ws\")) {\n            return readFromWebSocket(topic);\n        } else {\n            return read(topic);\n        }\n    }\n\n    private int read(String topic) {\n        int numMessagesRead = 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 (this.startMessageIdInclusive) {\n            LOG.warn(\"--start-message-id-inclusive has no effect on this version of pulsar-client.\");\n        }\n        if (maxPendingChunkedMessage > 0 || autoAckOldestChunkedMessageOnQueueFull) {\n            LOG.warn(\"Chunked-message knobs (--max_chunked_msg / --auto_ack_chunk_q_full) have no effect \"\n                    + \"on this version of pulsar-client.\");\n        }\n\n        Checkpoint startPosition = START_EARLIEST.equals(startMessageId)\n                ? Checkpoint.earliest() : Checkpoint.latest();\n\n        try (PulsarClient client = clientBuilder.build()) {\n            CheckpointConsumerBuilder<?> builder = client.newCheckpointConsumer(schema)\n                    .topic(topic)","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/CmdRead.java#L130-L166","documentation":"CmdRead.read() maps the --schema-type option to a Schema; this CLI only supports 'auto_consume' (Schema.AUTO_CONSUME) and 'bytes' (Schema.BYTES). Any other value throws IllegalArgumentException before a consumer is created.","triggerScenarios":"Running `pulsar-client read <topic> --schema-type json` (or avro, string, int8, etc.) — any value other than the two accepted literals.","commonSituations":"Copying --schema-type values from full pulsar-client docs into this V5 CLI; expecting JSON/Avro decoding in the read tool; typo like 'auto-consume' vs 'auto_consume'.","solutions":["Use --schema-type auto_consume to decode payloads per their embedded schema, or bytes for raw payloads.","Fix typos — the accepted values are exactly 'bytes' and 'auto_consume' (lowercase, underscore).","For richer schema support use the full Java client Consumer with the desired Schema."],"exampleFix":"// before\npulsar-client read my-topic --schema-type json\n// after\npulsar-client read my-topic --schema-type auto_consume","handlingStrategy":"validation","validationCode":"// bash\ncase \"$SCHEMA_TYPE\" in bytes|auto_consume) ;; *) echo \"schema type must be bytes or auto_consume\"; exit 1;; esac","typeGuard":"function isValidReadSchemaType(v) { return v === 'bytes' || v === 'auto_consume'; }","tryCatchPattern":"try { readCmd(schemaType); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"schema type must be\")) { /* default to auto_consume and retry */ } else throw e; }","preventionTips":["Use only bytes or auto_consume for --schema-type in this CLI.","Note the exact spelling: auto_consume with an underscore.","For other schemas, use the Java client Consumer instead of the CLI."],"tags":["cli","schema","validation","auto-consume"],"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-14T05:17:10.506Z"}