apache/pulsar · error · ParameterException
Cannot parse source-config
Error message
Cannot parse source-config
What it means
CmdSources.processArguments failed while parsing the --source-config YAML/JSON string into a config map; the string is malformed, so it cannot be applied to the SourceConfig and a ParameterException wraps the cause.
Source
Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdSources.java:486
resources.setRam(ram);
}
if (disk != null) {
if (resources == null) {
resources = new Resources();
}
resources.setDisk(disk);
}
if (resources != null) {
sourceConfig.setResources(resources);
}
try {
if (null != sourceConfigString) {
sourceConfig.setConfigs(parseConfigs(sourceConfigString));
}
} catch (Exception ex) {
throw new ParameterException("Cannot parse source-config", ex);
}
if (null != batchSourceConfigString) {
sourceConfig.setBatchSourceConfig(parseBatchSourceConfigs(batchSourceConfigString));
}
if (customRuntimeOptions != null) {
sourceConfig.setCustomRuntimeOptions(customRuntimeOptions);
}
if (secretsString != null) {
Type type = new TypeToken<Map<String, Object>>() {}.getType();
Map<String, Object> secretsMap = new Gson().fromJson(secretsString, type);
if (secretsMap == null) {
secretsMap = Collections.emptyMap();
}
sourceConfig.setSecrets(secretsMap);
}View on GitHub (pinned to 820761864e)
Solutions
- Fix the source-config string to be valid JSON/YAML
- Quote the argument properly in the shell
Example fix
// before
--source-config 'bootstrap.servers=localhost:9092'
// after
--source-config '{"bootstrap.servers":"localhost:9092"}' Defensive patterns
Strategy: validation
Validate before calling
const cfg = JSON.parse(sourceConfigString); // throws before invoking CLI if malformed
if (typeof cfg !== 'object' || Array.isArray(cfg)) throw new Error('source-config must be a JSON object'); Type guard
const isJsonObject = (s) => { try { return !Array.isArray(JSON.parse(s)) && typeof JSON.parse(s) === 'object'; } catch { return false; } }; Try / catch
try {
// run sources create with --source-config
} catch (e) {
if (e.message.includes('Cannot parse source-config')) { /* switch to --source-config-file */ }
throw e;
} Prevention
- Use valid JSON with quoted keys for --source-config
- Prefer --source-config-file over inline strings
- Validate with `jq .` before running the CLI
When it happens
Trigger: Passing `--source-config` with invalid JSON such as `key=value` pairs, YAML text, or JSON broken by shell quote stripping, e.g. `--source-config '{bootstrap.servers: localhost}'`.
Common situations: Bash removing inner double quotes so the JSON becomes invalid; using a properties-style string instead of a JSON object; trailing commas.
Related errors
- Cannot parse sink-config
- Need to specify a configuration file for broker
- No configuration file for Bookie
- Metadata store address argument is required (--metadata-stor
- Config file not specified. Please use -c, --config-file or -
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/45f6feef1698f13e.
Report an issue: GitHub.