{"record":{"id":"340c12f8870e8604","repo":"apolloconfig/apollo","slug":"invalid-audit-date-format-s","errorCode":null,"errorMessage":"Invalid audit date format: %s","messagePattern":"Invalid audit date 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":944,"sourceCode":"  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);\n    }\n    return targetEnv;\n  }\n\n  private Pageable pageable(Integer page, Integer size) {\n    return PageRequest.of(page(page), size(size));\n  }\n\n  private int page(Integer page) {\n    return page == null ? DEFAULT_PAGE : page;\n  }","sourceCodeStart":926,"sourceCodeEnd":962,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L926-L962","documentation":"Thrown by parseAuditDate when the date value is non-empty but does not match the expected 'yyyy-MM-dd HH:mm:ss.S' format (e.g. '2025-12-31 23:59:59.0'). This is used for audit-log date filtering parameters. If the value is blank/null, null is returned (no filter) — this error only fires when a value is provided but cannot be parsed.","triggerScenarios":"An audit-log query endpoint receives a date parameter in an unexpected format, such as ISO-8601 with 'T', epoch millis, or a date without milliseconds.","commonSituations":"The caller used a standard ISO date format; omitted the millisecond component; used '/' instead of '-' as separator; or passed a locale-specific format.","solutions":["Format the audit date as 'yyyy-MM-dd HH:mm:ss.S', e.g. '2025-12-31 23:59:59.0'.","Omit the date parameter if you do not need date-based filtering.","Ensure the milliseconds portion (.S) is included even if it is '.0'."],"exampleFix":"// before\ndate=2025-12-31T23:59:59\n\n// after\ndate=2025-12-31 23:59:59.0","handlingStrategy":"validation","validationCode":"// Format audit date as yyyy-MM-dd HH:mm:ss.S before sending\nif (value != null && !value.isEmpty()) {\n  try {\n    new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss.S\").parse(value);\n  } catch (ParseException e) {\n    throw new IllegalArgumentException(\"date must be yyyy-MM-dd HH:mm:ss.S format\");\n  }\n}","typeGuard":"function isValidAuditDateFormat(value: string): boolean {\n  return /^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}\\.\\d+$/.test(value);\n}","tryCatchPattern":null,"preventionTips":["Always include the millisecond component (.S) in audit date params.","Omit the date param if date filtering is not needed.","Use SimpleDateFormat to generate the correct format client-side."],"tags":["validation","openapi","bad-request","date-format","audit","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}