{"record":{"id":"62d09318479870ca","repo":"apolloconfig/apollo","slug":"please-enter-at-least-one-search-criterion-in-eith-62d093","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":"warning","filePath":"apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/GlobalSearchController.java","lineNumber":57,"sourceCode":"  private final GlobalSearchService globalSearchService;\n  private final PortalConfig portalConfig;\n\n  public GlobalSearchController(final GlobalSearchService globalSearchService,\n      final PortalConfig portalConfig) {\n    this.globalSearchService = globalSearchService;\n    this.portalConfig = portalConfig;\n  }\n\n  @PreAuthorize(value = \"@unifiedPermissionValidator.isSuperAdmin()\")\n  @GetMapping(\"/global-search/item-info/by-key-or-value\")\n  public SearchResponseEntity<List<ItemInfo>> getItemInfoBySearch(\n      @RequestParam(value = \"key\", required = false, defaultValue = \"\") String key,\n      @RequestParam(value = \"value\", required = false, defaultValue = \"\") String value) {\n\n    if (key.isEmpty() && value.isEmpty()) {\n      throw new BadRequestException(\n          \"Please enter at least one search criterion in either key or value.\");\n    }\n\n    return globalSearchService.getAllEnvItemInfoBySearch(key, value, 0,\n        portalConfig.getPerEnvSearchMaxResults());\n  }\n\n}\n","sourceCodeStart":39,"sourceCodeEnd":64,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/GlobalSearchController.java#L39-L64","documentation":"BadRequestException (HTTP 400) from GlobalSearchController.getItemInfoBySearch (GET /global-search/item-info/by-key-or-value), a super-admin-only endpoint. Both 'key' and 'value' default to '' and the handler rejects the call if both are empty — at least one search criterion is mandatory so the query is bounded.","triggerScenarios":"GET /global-search/item-info/by-key-or-value with neither ?key= nor ?value= provided, or both supplied but blank.","commonSituations":"Submitting the search form with no input; stripping whitespace to empty; a UI button enabled before any criterion is typed.","solutions":["Provide a non-empty ?key= or ?value= (or both).","Disable the submit button until at least one field has non-blank content.","Trim client-side but ensure something remains after trimming.","Validate the same rule before the request (see validationCode)."],"exampleFix":"// before\nGET /global-search/item-info/by-key-or-value\n\n// after\nGET /global-search/item-info/by-key-or-value?key=timeout","handlingStrategy":"validation","validationCode":"// At least one of key/value must be non-blank.\nString k = key == null ? \"\" : key.trim();\nString v = value == null ? \"\" : value.trim();\nif (k.isEmpty() && v.isEmpty()) {\n  throw new IllegalArgumentException(\"key or value is required\");\n}\n// then GET ...?key=<k>&value=<v>","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Disable the search button until one field is non-blank.","Trim inputs but ensure something remains.","Default both to '' but never submit both empty.","Note this endpoint requires super-admin."],"tags":["global-search","validation","bad-request","super-admin"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}