apache/pulsar · error · IllegalArgumentException
Field '${name}' cannot be null!
Error message
Field '${name}' cannot be null! What it means
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.
Source
Thrown at pulsar-config-validation/src/main/java/org/apache/pulsar/config/validation/ValidatorImpls.java:80
throw new IllegalArgumentException(String.format("Field '%s' must be a Positive Number", name));
}
@Override
public void validateField(String name, Object o) {
validateField(name, this.includeZero, o);
}
}
/**
* Validates if an object is not null.
*/
public static class NotNullValidator extends Validator {
@Override
public void validateField(String name, Object o) {
if (o == null) {
throw new IllegalArgumentException(String.format("Field '%s' cannot be null!", name));
}
}
}
/**
* Validates each entry in a list.
*/
public static class ListEntryTypeValidator extends Validator {
private Class<?> type;
public ListEntryTypeValidator(Map<String, Object> params) {
this.type = (Class<?>) params.get(ConfigValidationAnnotations.ValidatorParams.TYPE);
}
public static void validateField(String name, Class<?> type, Object o) {
ConfigValidationUtils.NestableFieldValidator validator = ConfigValidationUtils.listFv(type, false);
validator.validateField(name, o);View on GitHub (pinned to 820761864e)
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
Example fix
# before # advertisedAddress missing # after advertisedAddress=broker-1.example.com
Defensive patterns
Strategy: validation
Validate before calling
// before validateConfig
java.util.Set<String> notNullFields = java.util.Set.of("advertisedAddress", "clusterName");
for (String f : notNullFields) {
if (conf.get(f) == null) throw new IllegalStateException("required field missing: " + f);
} Try / catch
try {
ConfigValidation.validateConfig(conf);
} catch (IllegalArgumentException e) {
throw new IllegalStateException("Required config field is null: " + e.getMessage(), e);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Field ${name} must not be null
- ERROR_DECODING_JWT
- ${pd}${name} must be a ${cls.getName()}. (${field})
- Field ${name} must be an Iterable but was a ${field.getClass
- Field ${name} must be a Map
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/06827a0d38574834.
Report an issue: GitHub.