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
- 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).
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
- 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.
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
- Please enter at least one search criterion in either key or
- The App Id of path variable and request body is different
- Comment item's key or value should be blank.
- Comment item's comment should not be blank.
- value too long. length limit:%s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/62d09318479870ca.
Report an issue: GitHub.