{"record":{"id":"91ef84163644a993","repo":"apolloconfig/apollo","slug":"please-enter-at-least-one-search-criterion-in-eith","errorCode":null,"errorMessage":"Please enter at least one search criterion in either key or value.","messagePattern":"Please enter at least one search criterion in either key or value\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java","lineNumber":472,"sourceCode":"  public ResponseEntity<Void> deleteFavorite(Long favoriteId) {\n    requirePortalUserRequest();\n    favoriteService.deleteFavorite(favoriteId, currentUserId());\n    return ResponseEntity.ok().build();\n  }\n\n  @Override\n  public ResponseEntity<Void> topFavorite(Long favoriteId) {\n    requirePortalUserRequest();\n    favoriteService.adjustFavoriteToFirst(favoriteId, currentUserId());\n    return ResponseEntity.ok().build();\n  }\n\n  @Override\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isSuperAdmin()\")\n  public ResponseEntity<Object> searchItemInfoByKeyOrValue(String key, String value) {\n    requirePortalUserRequest();\n    if (StringUtils.isEmpty(key) && StringUtils.isEmpty(value)) {\n      throw new BadRequestException(\n          \"Please enter at least one search criterion in either key or value.\");\n    }\n    return ResponseEntity.ok(globalSearchService.getAllEnvItemInfoBySearch(key, value, 0,\n        portalConfig.getPerEnvSearchMaxResults()));\n  }\n\n  @Override\n  public ResponseEntity<List<Object>> findReleaseHistoriesByNamespace(String appId, String env,\n      String clusterName, String namespaceName, Integer page, Integer size) {\n    requirePortalUserRequest();\n    Env targetEnv = parseEnv(env);\n    if (unifiedPermissionValidator.shouldHideConfigToCurrentUser(appId, env, clusterName,\n        namespaceName)) {\n      return ResponseEntity.ok(Collections.emptyList());\n    }\n    List<ReleaseHistoryBO> histories = releaseHistoryService.findNamespaceReleaseHistory(appId,\n        targetEnv, clusterName, namespaceName, page(page), size(size));\n    return ResponseEntity.ok(asObjects(histories));","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java#L454-L490","documentation":"Thrown in searchItemInfoByKeyOrValue when both the key and value query parameters are null or empty. This global search endpoint searches across all environments for config items matching a key or value pattern, and Apollo requires at least one search criterion to prevent an unbounded full-table scan. This is a super-admin-only endpoint.","triggerScenarios":"A super-admin calls the global item search endpoint with no key and no value query parameter (both omitted or both empty strings).","commonSituations":"The caller called the endpoint with no query string; both params were programmatically set to empty strings; or the client library stripped null params and sent a bare request.","solutions":["Provide at least one of the key or value query parameters, e.g. ?key=timeout or ?value=3600.","If you need to enumerate all items, use the per-namespace items endpoint instead of the global search.","Validate client-side before sending: ensure key or value is non-empty before making the call."],"exampleFix":"// before\nGET /search/items?key=&value=\n\n// after\nGET /search/items?key=timeout","handlingStrategy":"validation","validationCode":"// Ensure at least one criterion before calling search\nif (StringUtils.isEmpty(key) && StringUtils.isEmpty(value)) {\n  throw new IllegalArgumentException(\"Provide key or value for search\");\n}","typeGuard":"function hasSearchCriterion(key: string | undefined, value: string | undefined): boolean {\n  return (!!key && key.trim().length > 0) || (!!value && value.trim().length > 0);\n}","tryCatchPattern":null,"preventionTips":["Always pass at least one non-empty search param.","Add a UI guard that disables the search button until a criterion is entered.","Document that empty searches are rejected to prevent client-side confusion."],"tags":["validation","openapi","bad-request","search","super-admin","apollo-portal"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}