{"record":{"id":"1732fcce6228a26f","repo":"apache/pulsar","slug":"cannot-specify-both-archive-and-sink-type","errorCode":null,"errorMessage":"Cannot specify both archive and sink-type","messagePattern":"Cannot specify both archive and sink-type","errorType":"validation","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSinks.java","lineNumber":532,"sourceCode":"\n            if (isNotBlank(subsName)) {\n                sinkConfig.setSourceSubscriptionName(subsName);\n            }\n\n            if (null != subsPosition) {\n                sinkConfig.setSourceSubscriptionPosition(subsPosition);\n            }\n\n            if (null != topicsPattern) {\n                sinkConfig.setTopicsPattern(topicsPattern);\n            }\n\n            if (parallelism != null) {\n                sinkConfig.setParallelism(parallelism);\n            }\n\n            if (archive != null && (sinkType != null || sinkConfig.getSinkType() != null)) {\n                throw new ParameterException(\"Cannot specify both archive and sink-type\");\n            }\n\n            if (null != archive) {\n                sinkConfig.setArchive(archive);\n            }\n\n            if (sinkType != null) {\n                sinkConfig.setArchive(validateSinkType(sinkType));\n            } else if (sinkConfig.getSinkType() != null) {\n                sinkConfig.setArchive(validateSinkType(sinkConfig.getSinkType()));\n            }\n\n            Resources resources = sinkConfig.getResources();\n            if (cpu != null) {\n                if (resources == null) {\n                    resources = new Resources();\n                }\n                resources.setCpu(cpu);","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSinks.java#L514-L550","documentation":"A Pulsar IO sink can be defined either by a custom NAR archive (--archive) or by a built-in connector type (--sink-type), never both, since the deployment mechanism is ambiguous. The CLI throws this ParameterException during argument processing when both are supplied.","triggerScenarios":"Running `pulsar-admin sinks create` (or update) with both `--archive /path/to/sink.nar` and `--sink-type <builtin-name>` (or a sinkConfig that already has sinkType set, e.g. via --sink-config-file).","commonSituations":"Copy-pasting example commands and appending a built-in type on top of an archive; combining a config file that sets sinkType with an explicit --archive flag.","solutions":["Remove --archive and keep --sink-type to use a built-in connector","Remove --sink-type and keep --archive to use a custom NAR","If a --sink-config-file sets sinkType, do not also pass --archive"],"exampleFix":"// before\npulsar-admin sinks create --archive ./my-sink.nar --sink-type cassandra ...\n// after\npulsar-admin sinks create --sink-type cassandra ...","handlingStrategy":"validation","validationCode":"const hasArchive = args.includes('--archive');\nconst hasSinkType = args.includes('--sink-type');\nif (hasArchive && hasSinkType) throw new Error('Pass either --archive or --sink-type, not both');","typeGuard":"const isSinkDeployment = (o) => o.archive == null || (o.sinkType == null && o.sinkConfig?.sinkType == null);","tryCatchPattern":"try {\n  // run sinks create\n} catch (e) {\n  if (e.message.includes('both archive and sink-type')) { /* strip one flag and retry */ }\n  throw e;\n}","preventionTips":["Choose archive OR sink-type when scripting sink creation","Check sink-config-file contents for an embedded sinkType before adding --archive","Wrap CLI invocations in a script that asserts mutually exclusive flags"],"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-14T05:17:10.506Z"}