{"record":{"id":"48b58a829de3a664","repo":"apache/pulsar","slug":"could-not-validate-source-config","errorCode":null,"errorMessage":"Could not validate source config: ","messagePattern":"Could not validate source config: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SourceConfigUtils.java","lineNumber":539,"sourceCode":"                        Class.forName(defn.getSourceConfigClass(), true, sourceFunction.getClassLoader());\n                validateSourceConfig(sourceConfig, configClass);\n            }\n        } catch (ClassNotFoundException e) {\n            throw new IllegalArgumentException(\"Could not find source config class\");\n        }\n\n    }\n\n    public static void validateSourceConfig(SourceConfig sourceConfig, Class<?> configClass) {\n        try {\n            Object configObject =\n                    ObjectMapperFactory.getMapper().getObjectMapper()\n                            .convertValue(sourceConfig.getConfigs(), configClass);\n            if (configObject != null) {\n                ConfigValidation.validateConfig(configObject);\n            }\n        } catch (IllegalArgumentException e) {\n            throw new IllegalArgumentException(\"Could not validate source config: \" + e.getMessage());\n        }\n    }\n}\n","sourceCodeStart":521,"sourceCodeEnd":543,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SourceConfigUtils.java#L521-L543","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the wrapped e.getMessage() in the exception to identify the failing field/conversion","Correct the configs JSON passed to the function so types and names match the declared config class fields","Fill in required fields or apply the documented default values for the connector's config","Add/align validation annotations on the config class if the class itself defines overly strict constraints"],"exampleFix":"// before\n// configs = {\"bootstrapServers\": \"kafka:9092\", \"topicName\": 123} // topicName is String\n// after\n// configs = {\"bootstrapServers\": \"kafka:9092\", \"topicName\": \"my-topic\"}","handlingStrategy":"validation","validationCode":"// pre-validate configs against the config class\nObject cfg = ObjectMapperFactory.getMapper().getObjectMapper()\n        .convertValue(sourceConfig.getConfigs(), configClass);\nConfigValidation.validateConfig(cfg); // same checks the library runs","typeGuard":null,"tryCatchPattern":"try {\n    SourceConfigUtils.validateSourceConfig(sourceConfig, configClass);\n} catch (IllegalArgumentException e) {\n    log.error(\"Source config invalid: {}\", e.getMessage());\n    throw e; // message includes the underlying field/conversion failure\n}","preventionTips":["Generate configs from the config class POJO rather than hand-written JSON","Match key names and types to the connector's documented config fields","Test function submission with pulsar-admin against a staging broker first"],"tags":["pulsar-functions","config-validation","json-deserialization","jackson"],"backgroundTag":"schema-validation-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}