apache/pulsar · error · IllegalArgumentException

Could not validate source config:

Error message

Could not validate source config: 

What it means

Wraps an IllegalArgumentException raised while converting the function's 'configs' JSON map into the declared source config class (Jackson convertValue) and running ConfigValidation.validateConfig on it. The original message is appended so the developer sees the actual deserialization or field-validation failure.

Source

Thrown at pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SourceConfigUtils.java:539

                        Class.forName(defn.getSourceConfigClass(), true, sourceFunction.getClassLoader());
                validateSourceConfig(sourceConfig, configClass);
            }
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Could not find source config class");
        }

    }

    public static void validateSourceConfig(SourceConfig sourceConfig, Class<?> configClass) {
        try {
            Object configObject =
                    ObjectMapperFactory.getMapper().getObjectMapper()
                            .convertValue(sourceConfig.getConfigs(), configClass);
            if (configObject != null) {
                ConfigValidation.validateConfig(configObject);
            }
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Could not validate source config: " + e.getMessage());
        }
    }
}

View on GitHub (pinned to 820761864e)

Solutions

  1. Read the wrapped e.getMessage() in the exception to identify the failing field/conversion
  2. Correct the configs JSON passed to the function so types and names match the declared config class fields
  3. Fill in required fields or apply the documented default values for the connector's config
  4. Add/align validation annotations on the config class if the class itself defines overly strict constraints

Example fix

// before
// configs = {"bootstrapServers": "kafka:9092", "topicName": 123} // topicName is String
// after
// configs = {"bootstrapServers": "kafka:9092", "topicName": "my-topic"}
Defensive patterns

Strategy: validation

Validate before calling

// pre-validate configs against the config class
Object cfg = ObjectMapperFactory.getMapper().getObjectMapper()
        .convertValue(sourceConfig.getConfigs(), configClass);
ConfigValidation.validateConfig(cfg); // same checks the library runs

Try / catch

try {
    SourceConfigUtils.validateSourceConfig(sourceConfig, configClass);
} catch (IllegalArgumentException e) {
    log.error("Source config invalid: {}", e.getMessage());
    throw e; // message includes the underlying field/conversion failure
}

Prevention

When it happens

Trigger: validateSourceConfig(sourceConfig, configClass) is called with sourceConfig.getConfigs() containing keys/types that do not map onto the config class fields, or field values that violate @ validation annotations enforced by ConfigValidation.

Common situations: Passing configs with wrong types (e.g. string where int expected) when submitting a function via CLI/REST; required config fields left empty; nested config keys misspelled so Jackson cannot map them; JSON fields removed/renamed after a connector upgrade.

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


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/48b58a829de3a664. Report an issue: GitHub.