apolloconfig/apollo · error · BadRequestException
ServerConfig.Value cannot be blank
Error message
ServerConfig.Value cannot be blank
What it means
Thrown by validateServerConfig when the ServerConfig body has a non-blank key but a blank value field (null, empty, or whitespace-only). Apollo requires every server config entry to have a value. This is the third and final check in the validateServerConfig chain.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:922
}
private String resolveConflictAction(String conflictAction) {
if (StringUtils.isEmpty(conflictAction)) {
return CONFLICT_ACTION_IGNORE;
}
validateConflictAction(conflictAction);
return conflictAction;
}
private void validateServerConfig(ServerConfig serverConfig) {
if (serverConfig == null) {
throw new BadRequestException("ServerConfig can not be null");
}
if (!org.springframework.util.StringUtils.hasText(serverConfig.getKey())) {
throw new BadRequestException("ServerConfig.Key cannot be blank");
}
if (!org.springframework.util.StringUtils.hasText(serverConfig.getValue())) {
throw new BadRequestException("ServerConfig.Value cannot be blank");
}
}
private Date parseConsumerExpires(String expires) {
if (!org.springframework.util.StringUtils.hasText(expires)) {
return DEFAULT_EXPIRES;
}
try {
return new SimpleDateFormat("yyyyMMddHHmmss").parse(expires);
} catch (ParseException e) {
throw new BadRequestException("Invalid expires format: %s", expires);
}
}
private Date parseAuditDate(String value) {
if (!org.springframework.util.StringUtils.hasText(value)) {
return null;
}View on GitHub (pinned to d95fc18d11)
Solutions
- Provide a non-blank value, e.g. {"key":"timeout","value":"30"}.
- If you need to represent an empty string as a value, note that Apollo's hasText check rejects it — use a placeholder or space if semantically appropriate.
- To delete a server config, use the delete endpoint rather than setting a blank value.
Example fix
// before
{"key":"timeout","value":""}
// after
{"key":"timeout","value":"0"} Defensive patterns
Strategy: validation
Validate before calling
// Validate value is non-blank before sending
if (!org.springframework.util.StringUtils.hasText(serverConfig.getValue())) {
throw new IllegalArgumentException("ServerConfig value must not be blank");
} Type guard
function hasNonBlankValue(body: { value?: string }): boolean {
return typeof body.value === 'string' && body.value.trim().length > 0;
} Prevention
- Always provide a non-blank value; use a placeholder if the intent is 'none'.
- Use the delete endpoint to remove configs, not blank values.
- Add client-side validation mirroring hasText for all required fields.
When it happens
Trigger: A server-config create/update request where the value field is missing, null, empty string, or whitespace-only.
Common situations: The caller intended to clear a config by setting an empty value, but Apollo treats blank as invalid; the value field was omitted from the JSON; or the value was set to a variable that evaluated to null.
Related errors
- ServerConfig can not be null
- ServerConfig.Key cannot be blank
- userIds should not be null or empty
- AppId not equal. AppId in path = %s, AppId in payload = %s
- operator should not be null or empty
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/09c9e17508031381.
Report an issue: GitHub.