{"record":{"id":"06827a0d38574834","repo":"apache/pulsar","slug":"field-name-cannot-be-null","errorCode":null,"errorMessage":"Field '${name}' cannot be null!","messagePattern":"Field '(.+?)' cannot be null!","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-config-validation/src/main/java/org/apache/pulsar/config/validation/ValidatorImpls.java","lineNumber":80,"sourceCode":"            throw new IllegalArgumentException(String.format(\"Field '%s' must be a Positive Number\", name));\n        }\n\n        @Override\n        public void validateField(String name, Object o) {\n            validateField(name, this.includeZero, o);\n        }\n    }\n\n    /**\n     * Validates if an object is not null.\n     */\n\n    public static class NotNullValidator extends Validator {\n\n        @Override\n        public void validateField(String name, Object o) {\n            if (o == null) {\n                throw new IllegalArgumentException(String.format(\"Field '%s' cannot be null!\", name));\n            }\n        }\n    }\n\n    /**\n     * Validates each entry in a list.\n     */\n    public static class ListEntryTypeValidator extends Validator {\n\n        private Class<?> type;\n\n        public ListEntryTypeValidator(Map<String, Object> params) {\n            this.type = (Class<?>) params.get(ConfigValidationAnnotations.ValidatorParams.TYPE);\n        }\n\n        public static void validateField(String name, Class<?> type, Object o) {\n            ConfigValidationUtils.NestableFieldValidator validator = ConfigValidationUtils.listFv(type, false);\n            validator.validateField(name, o);","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-config-validation/src/main/java/org/apache/pulsar/config/validation/ValidatorImpls.java#L62-L98","documentation":"ValidatorImpls.NotNullValidator.validateField throws IllegalArgumentException when the validated value is null. It is the simplest validator: any non-null object passes, null is rejected with a message naming the field.","triggerScenarios":"A config field validated with NotNullValidator (via @NotNullValidator annotation or programmatic Validator use) left null because the property was missing from the supplied config map/properties at validateConfig time.","commonSituations":"A required setting omitted from broker.conf/standalone.conf or from a programmatically-built config object; YAML/properties key misspelled so it deserializes to null.","solutions":["Set the missing field in the configuration file or properties map before validation","Fix the key spelling so the intended value is actually picked up","Give the field a default value in the config class if it is genuinely optional, and remove the NotNullValidator in that case"],"exampleFix":"# before\n# advertisedAddress missing\n# after\nadvertisedAddress=broker-1.example.com","handlingStrategy":"validation","validationCode":"// before validateConfig\njava.util.Set<String> notNullFields = java.util.Set.of(\"advertisedAddress\", \"clusterName\");\nfor (String f : notNullFields) {\n    if (conf.get(f) == null) throw new IllegalStateException(\"required field missing: \" + f);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ConfigValidation.validateConfig(conf);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Required config field is null: \" + e.getMessage(), e);\n}","preventionTips":["List all NotNullValidator fields from the config class and pre-check them at startup","Provide defaults in the config class for optional fields and drop the validator there","Beware key misspellings in properties files which silently yield null"],"tags":["config-validation","null","notnull"],"backgroundTag":"required-config-field-missing","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}