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

  1. Ensure releaseIds contains at least one valid numeric ID, e.g. releaseIds=123,456.
  2. Omit the request entirely if the release ID list is empty — querying instances not-in-zero-releases is not meaningful.
  3. 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

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


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