{"record":{"id":"7c438ccea26f1a68","repo":"apolloconfig/apollo","slug":"releaseids-should-not-be-empty","errorCode":null,"errorMessage":"releaseIds should not be empty","messagePattern":"releaseIds should not be empty","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/InstanceController.java","lineNumber":97,"sourceCode":"\n  @Override\n  public ResponseEntity<OpenInstancePageDTO> getByRelease(String env, Long releaseId, Integer page,\n      Integer size) {\n    ReleaseDTO release = findReleaseOrThrow(Env.valueOf(env), releaseId);\n    checkReleaseReadAllowed(env, release);\n    return ResponseEntity.ok(OpenApiModelConverters.fromInstancePageDTO(instanceService\n        .getByRelease(Env.valueOf(env), releaseId, resolvePage(page), resolvePageSize(size))));\n  }\n\n  @Override\n  public ResponseEntity<List<OpenInstanceDTO>> getByReleasesAndNamespaceNotIn(String env,\n      String appId, String clusterName, String namespaceName, String releaseIds) {\n    if (shouldHideConfigToPortalUser(appId, env, clusterName, namespaceName)) {\n      return ResponseEntity.ok(Collections.emptyList());\n    }\n    checkConfigReadAllowed(appId, env, clusterName, namespaceName);\n    if (releaseIds == null || releaseIds.trim().isEmpty()) {\n      throw new BadRequestException(\"releaseIds should not be empty\");\n    }\n\n    Set<Long> releaseIdSet;\n    try {\n      releaseIdSet = RELEASE_ID_SPLITTER.splitToStream(releaseIds).map(Long::parseLong)\n          .collect(Collectors.toSet());\n    } catch (NumberFormatException ex) {\n      throw new BadRequestException(\"releaseIds should be comma separated numbers\");\n    }\n    if (releaseIdSet.isEmpty()) {\n      throw new BadRequestException(\"releaseIds should not be empty\");\n    }\n    return ResponseEntity.ok(OpenApiModelConverters.fromInstanceDTOs(instanceService\n        .getByReleasesNotIn(Env.valueOf(env), appId, clusterName, namespaceName, releaseIdSet)));\n  }\n\n  @Override\n  public ResponseEntity<Integer> getInstanceCountByNamespace(String env, String appId,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/InstanceController.java#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — empty releaseIds passed to the API\nString releaseIds = ids.isEmpty() ? \"\" : ids.stream().map(String::valueOf).collect(Collectors.joining(\",\"));\nclient.get(\"/instances/not-in-releases?releaseIds=\" + releaseIds); // throws when ids is empty\n\n// after — guard against empty before calling\nif (!ids.isEmpty()) {\n    String releaseIds = ids.stream().map(String::valueOf).collect(Collectors.joining(\",\"));\n    client.get(\"/instances/not-in-releases?releaseIds=\" + releaseIds);\n}","handlingStrategy":"validation","validationCode":"// Before calling the not-in-releases endpoint, ensure releaseIds is non-empty\nif (releaseIds == null || releaseIds.trim().isEmpty()) {\n    // Skip the call or throw a client-side validation error\n    return Collections.emptyList(); // or throw new IllegalArgumentException(\"releaseIds must not be empty\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","openapi","instance","bad-request","input-validation","http-400"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}