apolloconfig/apollo · warning · BadRequestException

Please enter at least one search criterion in either key or

Error message

Please enter at least one search criterion in either key or value.

What it means

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.

Source

Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/GlobalSearchController.java:57

  private final GlobalSearchService globalSearchService;
  private final PortalConfig portalConfig;

  public GlobalSearchController(final GlobalSearchService globalSearchService,
      final PortalConfig portalConfig) {
    this.globalSearchService = globalSearchService;
    this.portalConfig = portalConfig;
  }

  @PreAuthorize(value = "@unifiedPermissionValidator.isSuperAdmin()")
  @GetMapping("/global-search/item-info/by-key-or-value")
  public SearchResponseEntity<List<ItemInfo>> getItemInfoBySearch(
      @RequestParam(value = "key", required = false, defaultValue = "") String key,
      @RequestParam(value = "value", required = false, defaultValue = "") String value) {

    if (key.isEmpty() && value.isEmpty()) {
      throw new BadRequestException(
          "Please enter at least one search criterion in either key or value.");
    }

    return globalSearchService.getAllEnvItemInfoBySearch(key, value, 0,
        portalConfig.getPerEnvSearchMaxResults());
  }

}

View on GitHub (pinned to d95fc18d11)

Solutions

  1. Provide a non-empty ?key= or ?value= (or both).
  2. Disable the submit button until at least one field has non-blank content.
  3. Trim client-side but ensure something remains after trimming.
  4. Validate the same rule before the request (see validationCode).

Example fix

// before
GET /global-search/item-info/by-key-or-value

// after
GET /global-search/item-info/by-key-or-value?key=timeout
Defensive patterns

Strategy: validation

Validate before calling

// At least one of key/value must be non-blank.
String k = key == null ? "" : key.trim();
String v = value == null ? "" : value.trim();
if (k.isEmpty() && v.isEmpty()) {
  throw new IllegalArgumentException("key or value is required");
}
// then GET ...?key=<k>&value=<v>

Prevention

When it happens

Trigger: GET /global-search/item-info/by-key-or-value with neither ?key= nor ?value= provided, or both supplied but blank.

Common situations: Submitting the search form with no input; stripping whitespace to empty; a UI button enabled before any criterion is typed.

Related errors


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