{"record":{"id":"6236b423200c646d","repo":"apache/pulsar","slug":"could-not-validate-sink-config","errorCode":null,"errorMessage":"Could not validate sink config: ","messagePattern":"Could not validate sink config: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SinkConfigUtils.java","lineNumber":765,"sourceCode":"            if (defn != null && defn.getSinkConfigClass() != null) {\n                Class<?> configClass = Class.forName(defn.getSinkConfigClass(), true, sinkFunction.getClassLoader());\n                validateSinkConfig(sinkConfig, configClass);\n            }\n        } catch (ClassNotFoundException e) {\n            throw new IllegalArgumentException(\"Could not find sink config class\", e);\n        }\n    }\n\n    public static void validateSinkConfig(SinkConfig sinkConfig, Class<?> configClass) {\n        try {\n            Object configObject =\n                    ObjectMapperFactory.getMapper().getObjectMapper()\n                            .convertValue(sinkConfig.getConfigs(), configClass);\n            if (configObject != null) {\n                ConfigValidation.validateConfig(configObject);\n            }\n        } catch (IllegalArgumentException e) {\n            throw new IllegalArgumentException(\"Could not validate sink config: \" + e.getMessage());\n        }\n    }\n}\n","sourceCodeStart":747,"sourceCodeEnd":769,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/SinkConfigUtils.java#L747-L769","documentation":"Thrown by the one-arg validateSinkConfig when converting the sink's configs map to the connector config class or validating it fails with IllegalArgumentException; the original message is prefixed with 'Could not validate sink config: '. It means the user-supplied configs do not conform to the connector's config class schema.","triggerScenarios":"SinkConfig.getConfigs() contains keys/types that cannot be mapped to the connector's config class fields (Jackson convertValue fails) or ConfigValidation.validateConfig rejects a missing/invalid required field.","commonSituations":"Missing required config keys (e.g. missing 'topics' or 'bootstrapServer'); wrong value type (string where number expected) in the sink config YAML; config key renamed between connector versions.","solutions":["Read the wrapped message after the prefix to see the exact field that failed","Fix the configs map in the sink config so every required field of the connector config class is present with the correct type","Consult the connector's config class (sinkConfigClass) for the expected field names and types"],"exampleFix":"// before\nsinkConfig.setConfigs(Map.of(\"bootstrapServer\", \"localhost:9092\")); // missing required 'topic'\n// after\nsinkConfig.setConfigs(Map.of(\n    \"bootstrapServer\", \"localhost:9092\",\n    \"topic\", \"my-topic\"));","handlingStrategy":"try-catch","validationCode":"// validate configs against the connector config class before submitting\nObject cfgObj = new ObjectMapper().convertValue(sinkConfig.getConfigs(), MyConnectorSinkConfig.class);\nConfigValidation.validateConfig(cfgObj);","typeGuard":null,"tryCatchPattern":"try {\n    admin.sinks().updateSink(tenant, namespace, cfg, null);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Could not validate sink config:\")) { /* log cause, fix configs map */ }\n    else throw e;\n}","preventionTips":["Validate configs locally against the connector's config class before deploy","Keep a schema/doc of required config keys per connector version","Bump config keys carefully when upgrading connector versions"],"tags":["pulsar","functions","config-validation","jackson","schema"],"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"}