apolloconfig/apollo · error · BadRequestException
releaseIds should not be empty
Error message
releaseIds should not be empty
What it means
Thrown by InstanceController.getByReleasesAndNamespaceNotIn when the releaseIds query parameter is null, empty, or contains only whitespace. This is the first guard before the parameter is parsed. The parameter is expected to be a comma-separated list of numeric release IDs. Maps to HTTP 400 BadRequestException.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/InstanceController.java:97
@Override
public ResponseEntity<OpenInstancePageDTO> getByRelease(String env, Long releaseId, Integer page,
Integer size) {
ReleaseDTO release = findReleaseOrThrow(Env.valueOf(env), releaseId);
checkReleaseReadAllowed(env, release);
return ResponseEntity.ok(OpenApiModelConverters.fromInstancePageDTO(instanceService
.getByRelease(Env.valueOf(env), releaseId, resolvePage(page), resolvePageSize(size))));
}
@Override
public ResponseEntity<List<OpenInstanceDTO>> getByReleasesAndNamespaceNotIn(String env,
String appId, String clusterName, String namespaceName, String releaseIds) {
if (shouldHideConfigToPortalUser(appId, env, clusterName, namespaceName)) {
return ResponseEntity.ok(Collections.emptyList());
}
checkConfigReadAllowed(appId, env, clusterName, namespaceName);
if (releaseIds == null || releaseIds.trim().isEmpty()) {
throw new BadRequestException("releaseIds should not be empty");
}
Set<Long> releaseIdSet;
try {
releaseIdSet = RELEASE_ID_SPLITTER.splitToStream(releaseIds).map(Long::parseLong)
.collect(Collectors.toSet());
} catch (NumberFormatException ex) {
throw new BadRequestException("releaseIds should be comma separated numbers");
}
if (releaseIdSet.isEmpty()) {
throw new BadRequestException("releaseIds should not be empty");
}
return ResponseEntity.ok(OpenApiModelConverters.fromInstanceDTOs(instanceService
.getByReleasesNotIn(Env.valueOf(env), appId, clusterName, namespaceName, releaseIdSet)));
}
@Override
public ResponseEntity<Integer> getInstanceCountByNamespace(String env, String appId,View on GitHub (pinned to d95fc18d11)
Solutions
- Ensure releaseIds contains at least one valid numeric ID, e.g. releaseIds=123,456.
- Omit the request entirely if the release ID list is empty — querying instances not-in-zero-releases is not meaningful.
- Validate client-side: if (releaseIds == null || releaseIds.isEmpty()) skip the call.
Example fix
// before — empty releaseIds passed to the API
String releaseIds = ids.isEmpty() ? "" : ids.stream().map(String::valueOf).collect(Collectors.joining(","));
client.get("/instances/not-in-releases?releaseIds=" + releaseIds); // throws when ids is empty
// after — guard against empty before calling
if (!ids.isEmpty()) {
String releaseIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
client.get("/instances/not-in-releases?releaseIds=" + releaseIds);
} Defensive patterns
Strategy: validation
Validate before calling
// Before calling the not-in-releases endpoint, ensure releaseIds is non-empty
if (releaseIds == null || releaseIds.trim().isEmpty()) {
// Skip the call or throw a client-side validation error
return Collections.emptyList(); // or throw new IllegalArgumentException("releaseIds must not be empty");
} Prevention
- Always check that releaseIds is non-null and non-blank before constructing the query string.
- In API client wrappers, validate required query parameters before the HTTP call.
- Use builder patterns that prevent empty mandatory parameters.
When it happens
Trigger: GET /openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/instances/not-in-releases?releaseIds= (empty value) or the releaseIds parameter is omitted entirely when the client omits it from the query string.
Common situations: A client constructs the URL conditionally and the releaseIds variable evaluates to null or empty string. Template-based URL builders that append empty query params. API clients that send releaseIds as an empty list serialized to an empty string.
Related errors
- releaseIds should be comma separated numbers
- Comment length should not exceed %s characters
- AppId not equal. AppId in path = %s, AppId in payload = %s
- Current user not found
- Current user not found
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/7c438ccea26f1a68.
Report an issue: GitHub.