kafka-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrey Pustovetov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (KAFKA-7407) Kafka Connect validation ignores errors for undefined configs
Date Thu, 13 Sep 2018 11:17:00 GMT
Andrey Pustovetov created KAFKA-7407:

             Summary: Kafka Connect validation ignores errors for undefined configs
                 Key: KAFKA-7407
                 URL: https://issues.apache.org/jira/browse/KAFKA-7407
             Project: Kafka
          Issue Type: Bug
          Components: KafkaConnect
    Affects Versions: 1.1.1
            Reporter: Andrey Pustovetov

*Test case*

Perform validation of a custom connector that defines {{ConfigDef}} with undefined dependent
configs, i.e. it uses {{ConfigDef.define()}} method where the config that is specified in
{{dependents}} argument is missing in this {{ConfigDef}}.

AR: validation successful
ER: validation failed with the error: {{Configuration is not defined}}


There are two places where undefined configs can be obtained:
# The undefined dependent configs can be returned here: {{AbstractHerder.validateBasicConnectorConfig()}}
-> {{ConfigDef.validateAll()}}
List<String> undefinedConfigKeys = undefinedDependentConfigs();
for (String undefinedConfigKey: undefinedConfigKeys) {
    ConfigValue undefinedConfigValue = new ConfigValue(undefinedConfigKey);
    undefinedConfigValue.addErrorMessage(undefinedConfigKey + " is referred in the dependents,
but not defined.");
    configValues.put(undefinedConfigKey, undefinedConfigValue);
# The undefined configs can be returned by custom code here: {{Connector.validate()}}

{{AbstractHerder.generateResult()}} method already contains the check for undefined configs,
but it doesn't increase {{errorCount}} variable
int errorCount = 0;
List<ConfigInfo> configInfoList = new LinkedList<>();

Map<String, ConfigValue> configValueMap = new HashMap<>();
for (ConfigValue configValue: configValues) {
    String configName = configValue.name();
    configValueMap.put(configName, configValue);
    if (!configKeys.containsKey(configName)) {
        configValue.addErrorMessage("Configuration is not defined: " + configName);
        configInfoList.add(new ConfigInfo(null, convertConfigValue(configValue, null)));
so Kafka Connect validation ignores the errors.

I suggest to add the following code after adding of the error message:
errorCount += configValue.errorMessages().size();

This message was sent by Atlassian JIRA

View raw message