apache/pulsar · error · IllegalArgumentException
Could not validate sink config:
Error message
Could not validate sink config:
What it means
Thrown by the one-arg validateSinkConfig when converting the sink's configs map to the connector config class or validating it fails with IllegalArgumentException; the original message is prefixed with 'Could not validate sink config: '. It means the user-supplied configs do not conform to the connector's config class schema.
Source
Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SinkConfigUtils.java:765
if (defn != null && defn.getSinkConfigClass() != null) {
Class<?> configClass = Class.forName(defn.getSinkConfigClass(), true, sinkFunction.getClassLoader());
validateSinkConfig(sinkConfig, configClass);
}
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not find sink config class", e);
}
}
public static void validateSinkConfig(SinkConfig sinkConfig, Class<?> configClass) {
try {
Object configObject =
ObjectMapperFactory.getMapper().getObjectMapper()
.convertValue(sinkConfig.getConfigs(), configClass);
if (configObject != null) {
ConfigValidation.validateConfig(configObject);
}
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Could not validate sink config: " + e.getMessage());
}
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Read the wrapped message after the prefix to see the exact field that failed
- Fix the configs map in the sink config so every required field of the connector config class is present with the correct type
- Consult the connector's config class (sinkConfigClass) for the expected field names and types
Example fix
// before
sinkConfig.setConfigs(Map.of("bootstrapServer", "localhost:9092")); // missing required 'topic'
// after
sinkConfig.setConfigs(Map.of(
"bootstrapServer", "localhost:9092",
"topic", "my-topic")); Defensive patterns
Strategy: try-catch
Validate before calling
// validate configs against the connector config class before submitting Object cfgObj = new ObjectMapper().convertValue(sinkConfig.getConfigs(), MyConnectorSinkConfig.class); ConfigValidation.validateConfig(cfgObj);
Try / catch
try {
admin.sinks().updateSink(tenant, namespace, cfg, null);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Could not validate sink config:")) { /* log cause, fix configs map */ }
else throw e;
} Prevention
- Validate configs locally against the connector's config class before deploy
- Keep a schema/doc of required config keys per connector version
- Bump config keys carefully when upgrading connector versions
When it happens
Trigger: SinkConfig.getConfigs() contains keys/types that cannot be mapped to the connector's config class fields (Jackson convertValue fails) or ConfigValidation.validateConfig rejects a missing/invalid required field.
Common situations: Missing required config keys (e.g. missing 'topics' or 'bootstrapServer'); wrong value type (string where number expected) in the sink config YAML; config key renamed between connector versions.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Topic %s has an incorrect schema Info
- Only one of schemaType or serdeClassName should be set in in
- Only one of outputSchemaType or outputSerdeClassName should
- Sink Names differ
- Subscription Name cannot be altered
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/6236b423200c646d.
Report an issue: GitHub.