{"record":{"id":"e57a2320480958e3","repo":"apolloconfig/apollo","slug":"invalid-expires-format-s","errorCode":null,"errorMessage":"Invalid expires format: %s","messagePattern":"Invalid expires format: (.+?)","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java","lineNumber":933,"sourceCode":"    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    }\n    try {\n      return new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss.S\").parse(value);\n    } catch (ParseException e) {\n      throw new BadRequestException(\"Invalid audit date format: %s\", value);\n    }\n  }\n\n  private Env parseEnv(String env) {\n    Env targetEnv = Env.transformEnv(env);\n    if (Env.UNKNOWN.equals(targetEnv)) {\n      throw BadRequestException.invalidEnvFormat(env);","sourceCodeStart":915,"sourceCodeEnd":951,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L915-L951","documentation":"Thrown by parseConsumerExpires when the expires parameter is non-empty but does not match the expected 'yyyyMMddHHmmss' date format (e.g. '20251231235959'). Apollo uses this 14-digit timestamp to set consumer token expiration. If the parameter is blank/null, a default expiration is applied — this error only fires when a value is provided but is malformed.","triggerScenarios":"A consumer-creation or token-creation request includes an expires parameter that does not conform to the yyyyMMddHHmmss pattern (e.g. ISO-8601 '2025-12-31T23:59:59Z', Unix timestamp, or '2025/12/31').","commonSituations":"The caller used a standard date format instead of Apollo's custom compact format; the timestamp had separators like dashes or colons; or only the date portion was provided without the time component.","solutions":["Format the expires value as yyyyMMddHHmmss, e.g. '20251231235959' for Dec 31, 2025 23:59:59.","Omit the expires parameter entirely to use the default expiration.","Use a date formatter in your client code to generate the correct format."],"exampleFix":"// before\nexpires=2025-12-31T23:59:59Z\n\n// after\nexpires=20251231235959","handlingStrategy":"validation","validationCode":"// Format expires as yyyyMMddHHmmss before sending\nif (expires != null && !expires.isEmpty()) {\n  try {\n    new SimpleDateFormat(\"yyyyMMddHHmmss\").parse(expires);\n  } catch (ParseException e) {\n    throw new IllegalArgumentException(\"expires must be yyyyMMddHHmmss format\");\n  }\n}\n// Or generate it:\nString expires = new SimpleDateFormat(\"yyyyMMddHHmmss\").format(targetDate);","typeGuard":"function isValidExpiresFormat(expires: string): boolean {\n  return /^\\d{14}$/.test(expires);\n}","tryCatchPattern":null,"preventionTips":["Generate the expires value with a SimpleDateFormat('yyyyMMddHHmmss') in client code.","Omit expires to use the default expiration if exact control is not needed.","Document the exact 14-digit format in client integration guides."],"tags":["validation","openapi","bad-request","date-format","consumer","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}