apolloconfig/apollo · error · BadRequestException
Invalid expires format: %s
Error message
Invalid expires format: %s
What it means
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.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:933
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;
}
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);View on GitHub (pinned to d95fc18d11)
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.
Example fix
// before expires=2025-12-31T23:59:59Z // after expires=20251231235959
Defensive patterns
Strategy: validation
Validate before calling
// Format expires as yyyyMMddHHmmss before sending
if (expires != null && !expires.isEmpty()) {
try {
new SimpleDateFormat("yyyyMMddHHmmss").parse(expires);
} catch (ParseException e) {
throw new IllegalArgumentException("expires must be yyyyMMddHHmmss format");
}
}
// Or generate it:
String expires = new SimpleDateFormat("yyyyMMddHHmmss").format(targetDate); Type guard
function isValidExpiresFormat(expires: string): boolean {
return /^\d{14}$/.test(expires);
} Prevention
- 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.
When it happens
Trigger: 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').
Common situations: 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.
Related errors
- operator should not be null or empty
- Params(AppId) can not be empty.
- Params(NamespaceName) can not be empty.
- Invalid audit date format: %s
- userIds should not be null or empty
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/e57a2320480958e3.
Report an issue: GitHub.