apolloconfig/apollo · error · 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
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.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/PortalManagementController.java:472
public ResponseEntity<Void> deleteFavorite(Long favoriteId) {
requirePortalUserRequest();
favoriteService.deleteFavorite(favoriteId, currentUserId());
return ResponseEntity.ok().build();
}
@Override
public ResponseEntity<Void> topFavorite(Long favoriteId) {
requirePortalUserRequest();
favoriteService.adjustFavoriteToFirst(favoriteId, currentUserId());
return ResponseEntity.ok().build();
}
@Override
@PreAuthorize(value = "@unifiedPermissionValidator.isSuperAdmin()")
public ResponseEntity<Object> searchItemInfoByKeyOrValue(String key, String value) {
requirePortalUserRequest();
if (StringUtils.isEmpty(key) && StringUtils.isEmpty(value)) {
throw new BadRequestException(
"Please enter at least one search criterion in either key or value.");
}
return ResponseEntity.ok(globalSearchService.getAllEnvItemInfoBySearch(key, value, 0,
portalConfig.getPerEnvSearchMaxResults()));
}
@Override
public ResponseEntity<List<Object>> findReleaseHistoriesByNamespace(String appId, String env,
String clusterName, String namespaceName, Integer page, Integer size) {
requirePortalUserRequest();
Env targetEnv = parseEnv(env);
if (unifiedPermissionValidator.shouldHideConfigToCurrentUser(appId, env, clusterName,
namespaceName)) {
return ResponseEntity.ok(Collections.emptyList());
}
List<ReleaseHistoryBO> histories = releaseHistoryService.findNamespaceReleaseHistory(appId,
targetEnv, clusterName, namespaceName, page(page), size(size));
return ResponseEntity.ok(asObjects(histories));View on GitHub (pinned to d95fc18d11)
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.
Example fix
// before GET /search/items?key=&value= // after GET /search/items?key=timeout
Defensive patterns
Strategy: validation
Validate before calling
// Ensure at least one criterion before calling search
if (StringUtils.isEmpty(key) && StringUtils.isEmpty(value)) {
throw new IllegalArgumentException("Provide key or value for search");
} Type guard
function hasSearchCriterion(key: string | undefined, value: string | undefined): boolean {
return (!!key && key.trim().length > 0) || (!!value && value.trim().length > 0);
} Prevention
- 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.
When it happens
Trigger: A super-admin calls the global item search endpoint with no key and no value query parameter (both omitted or both empty strings).
Common situations: 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.
Related errors
- userIds should not be null or empty
- AppId not equal. AppId in path = %s, AppId in payload = %s
- operator should not be null or empty
- Params(AppId) can not be empty.
- Params(NamespaceName) can not be empty.
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/91ef84163644a993.
Report an issue: GitHub.