apache/pulsar · error · ParameterException
Cannot specify both archive and sink-type
Error message
Cannot specify both archive and sink-type
What it means
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.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSinks.java:532
if (isNotBlank(subsName)) {
sinkConfig.setSourceSubscriptionName(subsName);
}
if (null != subsPosition) {
sinkConfig.setSourceSubscriptionPosition(subsPosition);
}
if (null != topicsPattern) {
sinkConfig.setTopicsPattern(topicsPattern);
}
if (parallelism != null) {
sinkConfig.setParallelism(parallelism);
}
if (archive != null && (sinkType != null || sinkConfig.getSinkType() != null)) {
throw new ParameterException("Cannot specify both archive and sink-type");
}
if (null != archive) {
sinkConfig.setArchive(archive);
}
if (sinkType != null) {
sinkConfig.setArchive(validateSinkType(sinkType));
} else if (sinkConfig.getSinkType() != null) {
sinkConfig.setArchive(validateSinkType(sinkConfig.getSinkType()));
}
Resources resources = sinkConfig.getResources();
if (cpu != null) {
if (resources == null) {
resources = new Resources();
}
resources.setCpu(cpu);View on GitHub (pinned to 820761864e)
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
Example fix
// before pulsar-admin sinks create --archive ./my-sink.nar --sink-type cassandra ... // after pulsar-admin sinks create --sink-type cassandra ...
Defensive patterns
Strategy: validation
Validate before calling
const hasArchive = args.includes('--archive');
const hasSinkType = args.includes('--sink-type');
if (hasArchive && hasSinkType) throw new Error('Pass either --archive or --sink-type, not both'); Type guard
const isSinkDeployment = (o) => o.archive == null || (o.sinkType == null && o.sinkConfig?.sinkType == null);
Try / catch
try {
// run sinks create
} catch (e) {
if (e.message.includes('both archive and sink-type')) { /* strip one flag and retry */ }
throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Cannot specify both archive and source-type
- Sink archive not specified
- Sink Archive file %s does not exist
- Invalid sink type '%s' -- Available sinks are: %s
- You must specify a name for the sink
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/1732fcce6228a26f.
Report an issue: GitHub.