apolloconfig/apollo · error · BadRequestException

Invalid audit date format: %s

Error message

Invalid audit date format: %s

What it means

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.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:944

  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;
    }
    try {
      return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").parse(value);
    } catch (ParseException e) {
      throw new BadRequestException("Invalid audit date format: %s", value);
    }
  }

  private Env parseEnv(String env) {
    Env targetEnv = Env.transformEnv(env);
    if (Env.UNKNOWN.equals(targetEnv)) {
      throw BadRequestException.invalidEnvFormat(env);
    }
    return targetEnv;
  }

  private Pageable pageable(Integer page, Integer size) {
    return PageRequest.of(page(page), size(size));
  }

  private int page(Integer page) {
    return page == null ? DEFAULT_PAGE : page;
  }

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Format the audit date as 'yyyy-MM-dd HH:mm:ss.S', e.g. '2025-12-31 23:59:59.0'.
  2. Omit the date parameter if you do not need date-based filtering.
  3. Ensure the milliseconds portion (.S) is included even if it is '.0'.

Example fix

// before
date=2025-12-31T23:59:59

// after
date=2025-12-31 23:59:59.0
Defensive patterns

Strategy: validation

Validate before calling

// Format audit date as yyyy-MM-dd HH:mm:ss.S before sending
if (value != null && !value.isEmpty()) {
  try {
    new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").parse(value);
  } catch (ParseException e) {
    throw new IllegalArgumentException("date must be yyyy-MM-dd HH:mm:ss.S format");
  }
}

Type guard

function isValidAuditDateFormat(value: string): boolean {
  return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+$/.test(value);
}

Prevention

When it happens

Trigger: 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.

Common situations: The caller used a standard ISO date format; omitted the millisecond component; used '/' instead of '-' as separator; or passed a locale-specific format.

Related errors


AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14). Data as JSON: /api/errors/340c12f8870e8604. Report an issue: GitHub.