{"record":{"id":"f0d7c07580804440","repo":"apache/pulsar","slug":"cannot-specify-both-archive-and-source-type","errorCode":null,"errorMessage":"Cannot specify both archive and source-type","messagePattern":"Cannot specify both archive and source-type","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSources.java","lineNumber":443,"sourceCode":"                sourceConfig.setSerdeClassName(deserializationClassName);\n            }\n            if (null != schemaType) {\n                sourceConfig.setSchemaType(schemaType);\n            }\n\n            if (null != batchBuilder) {\n                sourceConfig.setBatchBuilder(batchBuilder);\n            }\n\n            if (null != processingGuarantees) {\n                sourceConfig.setProcessingGuarantees(processingGuarantees);\n            }\n            if (parallelism != null) {\n                sourceConfig.setParallelism(parallelism);\n            }\n\n            if (archive != null && (sourceType != null || sourceConfig.getSourceType() != null)) {\n                throw new ParameterException(\"Cannot specify both archive and source-type\");\n            }\n\n            if (archive != null) {\n                sourceConfig.setArchive(archive);\n            }\n\n            if (sourceType != null) {\n                sourceConfig.setArchive(validateSourceType(sourceType));\n            } else if (sourceConfig.getSourceType() != null) {\n                sourceConfig.setArchive(validateSourceType(sourceConfig.getSourceType()));\n            }\n\n            Resources resources = sourceConfig.getResources();\n            if (cpu != null) {\n                if (resources == null) {\n                    resources = new Resources();\n                }\n                resources.setCpu(cpu);","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSources.java#L425-L461","documentation":"Mirror of the sinks rule for sources: a source is deployed either via a custom NAR archive (--archive) or a built-in connector type (--source-type), and supplying both is ambiguous, so a ParameterException is thrown.","triggerScenarios":"Running `pulsar-admin sources create` (or update) with both `--archive` and `--source-type`, or with --archive while a config (--source-config-file) already sets sourceType.","commonSituations":"Appending --source-type to an existing archive-based command; config file already containing sourceType while the user also passes --archive.","solutions":["Keep only --source-type for built-in connectors","Keep only --archive for custom NARs","Remove sourceType from the source config JSON when using --archive"],"exampleFix":"// before\npulsar-admin sources create --archive ./src.nar --source-type kafka ...\n// after\npulsar-admin sources create --source-type kafka ...","handlingStrategy":"validation","validationCode":"const hasArchive = args.includes('--archive');\nconst hasSourceType = args.includes('--source-type');\nif (hasArchive && hasSourceType) throw new Error('Pass either --archive or --source-type, not both');","typeGuard":"const isSourceDeployment = (o) => o.archive == null || (o.sourceType == null && o.sourceConfig?.sourceType == null);","tryCatchPattern":"try {\n  // run sources create\n} catch (e) {\n  if (e.message.includes('both archive and source-type')) { /* remove one flag */ }\n  throw e;\n}","preventionTips":["Pick archive OR source-type per deployment","Inspect source-config JSON for embedded sourceType","Enforce flag exclusivity in deployment scripts"],"tags":["cli","pulsar-io","conflict"],"backgroundTag":"conflicting-arguments","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"}