{"record":{"id":"f4caf523e327551a","repo":"apache/pulsar","slug":"must-specify-type-of-topic-to-be-created-possible","errorCode":null,"errorMessage":"Must specify type of topic to be created. Possible values: (partitioned, non-partitioned)","messagePattern":"Must specify type of topic to be created\\. Possible values: \\(partitioned, non-partitioned\\)","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java","lineNumber":657,"sourceCode":"        @Option(names = { \"--type\", \"-t\" }, description = \"Type of topic to be auto-created. \"\n                + \"Possible values: (partitioned, non-partitioned). Default value: non-partitioned\")\n        private String type = \"non-partitioned\";\n\n        @Option(names = { \"--num-partitions\", \"-n\" }, description = \"Default number of partitions of topic to \"\n                + \"be auto-created, applicable to partitioned topics only\", required = false)\n        private Integer defaultNumPartitions = null;\n\n        @Override\n        void run() throws PulsarAdminException {\n            String namespace = validateNamespace(namespaceName);\n            type = type.toLowerCase().trim();\n\n            if (enable == disable) {\n                throw new ParameterException(\"Need to specify either --enable or --disable\");\n            }\n            if (enable) {\n                if (!TopicType.isValidTopicType(type)) {\n                    throw new ParameterException(\"Must specify type of topic to be created. \"\n                            + \"Possible values: (partitioned, non-partitioned)\");\n                }\n\n                if (TopicType.PARTITIONED.toString().equals(type)\n                        && (defaultNumPartitions == null || defaultNumPartitions <= 0)) {\n                    throw new ParameterException(\"Must specify num-partitions or num-partitions > 0 \"\n                            + \"for partitioned topic type.\");\n                }\n            }\n            getAdmin().namespaces().setAutoTopicCreation(namespace,\n                    AutoTopicCreationOverride.builder()\n                            .allowAutoTopicCreation(enable)\n                            .topicType(type)\n                            .defaultNumPartitions(defaultNumPartitions)\n                            .build());\n        }\n    }\n","sourceCodeStart":639,"sourceCodeEnd":675,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdNamespaces.java#L639-L675","documentation":"Thrown when --enable is set but the --type value is not one of the accepted TopicType names (partitioned, non-partitioned). TopicType.isValidTopicType(type) fails, so the CLI rejects the auto-topic-creation override rather than sending an invalid type to the broker.","triggerScenarios":"Running `set-auto-topic-creation --enable` with --type omitted (null/empty), misspelled ('partitoned'), wrong case ('Partitioned'), or a value like 'schema-ful' that is not a TopicType.","commonSituations":"Forgetting --type because it feels implied by --enable; using topic-domain names (persistent / non-persistent) instead of TopicType names; case issues from variable interpolation.","solutions":["Pass --type partitioned or --type non-partitioned (lowercase) whenever --enable is used","Fix spelling/casing of the type value","If disabling auto topic creation, --type is not needed; only pass it when enabling","Set --default-num-partitions too when type is partitioned (see error 869)"],"exampleFix":"// before\npulsar-admin namespaces set-auto-topic-creation t/ns --enable --type Partitioned\n// after\npulsar-admin namespaces set-auto-topic-creation t/ns --enable --type partitioned --default-num-partitions 4","handlingStrategy":"validation","validationCode":"if [ \"$ENABLE\" = true ]; then\n  case \"$TYPE\" in partitioned|non-partitioned) ;; *) echo \"--type must be partitioned or non-partitioned\"; exit 1;; esac\nfi","typeGuard":"// Java\nboolean isValidTopicType(String t) {\n    return \"partitioned\".equals(t) || \"non-partitioned\".equals(t);\n}","tryCatchPattern":"try { ... } catch (ParameterException e) { /* bad topic type: use partitioned|non-partitioned */ }","preventionTips":["When enabling, always pass --type with lowercase partitioned or non-partitioned","Do not use persistent/non-persistent as values — those are topic domains","Only pass --type when --enable is used"],"tags":["cli","argument-validation","auto-topic-creation","pulsar-admin"],"backgroundTag":"invalid-enum-value","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"}