{"record":{"id":"09c9e17508031381","repo":"apolloconfig/apollo","slug":"serverconfig-value-cannot-be-blank","errorCode":null,"errorMessage":"ServerConfig.Value cannot be blank","messagePattern":"ServerConfig\\.Value cannot be blank","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java","lineNumber":922,"sourceCode":"  }\n\n  private String resolveConflictAction(String conflictAction) {\n    if (StringUtils.isEmpty(conflictAction)) {\n      return CONFLICT_ACTION_IGNORE;\n    }\n    validateConflictAction(conflictAction);\n    return conflictAction;\n  }\n\n  private void validateServerConfig(ServerConfig serverConfig) {\n    if (serverConfig == null) {\n      throw new BadRequestException(\"ServerConfig can not be null\");\n    }\n    if (!org.springframework.util.StringUtils.hasText(serverConfig.getKey())) {\n      throw new BadRequestException(\"ServerConfig.Key cannot be blank\");\n    }\n    if (!org.springframework.util.StringUtils.hasText(serverConfig.getValue())) {\n      throw new BadRequestException(\"ServerConfig.Value cannot be blank\");\n    }\n  }\n\n  private Date parseConsumerExpires(String expires) {\n    if (!org.springframework.util.StringUtils.hasText(expires)) {\n      return DEFAULT_EXPIRES;\n    }\n    try {\n      return new SimpleDateFormat(\"yyyyMMddHHmmss\").parse(expires);\n    } catch (ParseException e) {\n      throw new BadRequestException(\"Invalid expires format: %s\", expires);\n    }\n  }\n\n  private Date parseAuditDate(String value) {\n    if (!org.springframework.util.StringUtils.hasText(value)) {\n      return null;\n    }","sourceCodeStart":904,"sourceCodeEnd":940,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L904-L940","documentation":"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.","triggerScenarios":"A server-config create/update request where the value field is missing, null, empty string, or whitespace-only.","commonSituations":"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.","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."],"exampleFix":"// before\n{\"key\":\"timeout\",\"value\":\"\"}\n\n// after\n{\"key\":\"timeout\",\"value\":\"0\"}","handlingStrategy":"validation","validationCode":"// Validate value is non-blank before sending\nif (!org.springframework.util.StringUtils.hasText(serverConfig.getValue())) {\n  throw new IllegalArgumentException(\"ServerConfig value must not be blank\");\n}","typeGuard":"function hasNonBlankValue(body: { value?: string }): boolean {\n  return typeof body.value === 'string' && body.value.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","openapi","bad-request","server-config","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}