apache/pulsar · error · ParameterException
Cannot specify both archive and source-type
Error message
Cannot specify both archive and source-type
What it means
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.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSources.java:443
sourceConfig.setSerdeClassName(deserializationClassName);
}
if (null != schemaType) {
sourceConfig.setSchemaType(schemaType);
}
if (null != batchBuilder) {
sourceConfig.setBatchBuilder(batchBuilder);
}
if (null != processingGuarantees) {
sourceConfig.setProcessingGuarantees(processingGuarantees);
}
if (parallelism != null) {
sourceConfig.setParallelism(parallelism);
}
if (archive != null && (sourceType != null || sourceConfig.getSourceType() != null)) {
throw new ParameterException("Cannot specify both archive and source-type");
}
if (archive != null) {
sourceConfig.setArchive(archive);
}
if (sourceType != null) {
sourceConfig.setArchive(validateSourceType(sourceType));
} else if (sourceConfig.getSourceType() != null) {
sourceConfig.setArchive(validateSourceType(sourceConfig.getSourceType()));
}
Resources resources = sourceConfig.getResources();
if (cpu != null) {
if (resources == null) {
resources = new Resources();
}
resources.setCpu(cpu);View on GitHub (pinned to 820761864e)
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
Example fix
// before pulsar-admin sources create --archive ./src.nar --source-type kafka ... // after pulsar-admin sources create --source-type kafka ...
Defensive patterns
Strategy: validation
Validate before calling
const hasArchive = args.includes('--archive');
const hasSourceType = args.includes('--source-type');
if (hasArchive && hasSourceType) throw new Error('Pass either --archive or --source-type, not both'); Type guard
const isSourceDeployment = (o) => o.archive == null || (o.sourceType == null && o.sourceConfig?.sourceType == null);
Try / catch
try {
// run sources create
} catch (e) {
if (e.message.includes('both archive and source-type')) { /* remove one flag */ }
throw e;
} Prevention
- Pick archive OR source-type per deployment
- Inspect source-config JSON for embedded sourceType
- Enforce flag exclusivity in deployment scripts
When it happens
Trigger: 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.
Common situations: Appending --source-type to an existing archive-based command; config file already containing sourceType while the user also passes --archive.
Related errors
- Cannot specify both archive and sink-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/f0d7c07580804440.
Report an issue: GitHub.