You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Andrey Pustovetov (JIRA)" <ji...@apache.org> on 2018/09/13 11:17:00 UTC

[jira] [Created] (KAFKA-7407) Kafka Connect validation ignores errors for undefined configs

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}}

*Description*

There are two places where undefined configs can be obtained:
# The undefined dependent configs can be returned here: {{AbstractHerder.validateBasicConnectorConfig()}} -> {{ConfigDef.validateAll()}}
{code:java}
List<String> undefinedConfigKeys = undefinedDependentConfigs();
for (String undefinedConfigKey: undefinedConfigKeys) {
    ConfigValue undefinedConfigValue = new ConfigValue(undefinedConfigKey);
    undefinedConfigValue.addErrorMessage(undefinedConfigKey + " is referred in the dependents, but not defined.");
    undefinedConfigValue.visible(false);
    configValues.put(undefinedConfigKey, undefinedConfigValue);
}
{code}
# 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
{code:java}
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)));
    }
}
{code}
so Kafka Connect validation ignores the errors.

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



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)