Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-7407

Kafka Connect validation ignores errors for undefined configs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.1.1
    • None
    • KafkaConnect
    • None

    Description

      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:

      1. 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.");
            undefinedConfigValue.visible(false);
            configValues.put(undefinedConfigKey, undefinedConfigValue);
        }
        
      2. 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();
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jchipmunk Andrey Pustovetov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: