apolloconfig/apollo · warning · BadRequestException
favorite not exist
Error message
favorite not exist
What it means
Thrown as a BadRequestException by FavoriteService.checkUserOperatePermission() when the favorite parameter is null. This private method guards update/delete/adjust-position operations. A null favorite means the referenced favorite ID was not found by the repository before the permission check, indicating the favorite doesn't exist.
Source
Thrown at apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/FavoriteService.java:128
public void adjustFavoriteToFirst(long favoriteId, String loginUserId) {
Favorite favorite = favoriteRepository.findById(favoriteId).orElse(null);
checkUserOperatePermission(favorite, loginUserId);
String userId = favorite.getUserId();
Favorite firstFavorite =
favoriteRepository.findFirstByUserIdOrderByPositionAscDataChangeCreatedTimeAsc(userId);
long minPosition = firstFavorite.getPosition();
favorite.setPosition(minPosition - 1);
favoriteRepository.save(favorite);
}
private void checkUserOperatePermission(Favorite favorite, String loginUserId) {
if (favorite == null) {
throw new BadRequestException("favorite not exist");
}
if (!Objects.equals(loginUserId, favorite.getUserId())) {
throw new BadRequestException("can not operate other person's favorite");
}
}
public void batchDeleteByAppId(String appId, String operator) {
favoriteRepository.batchDeleteByAppId(appId, operator);
}
}
View on GitHub (pinned to d95fc18d11)
Solutions
- Verify the favorite ID exists before attempting to operate on it by calling the favorite query API.
- Handle a 'not found' response gracefully in the UI by refreshing the favorites list.
- Check if the favorite was deleted by another session or an admin batch delete (batchDeleteByAppId).
- Ensure the client does not cache stale favorite IDs across sessions.
Defensive patterns
Strategy: validation
Validate before calling
// Check favorite exists before operating
Favorite favorite = favoriteRepository.findById(favoriteId).orElse(null);
if (favorite == null) {
// handle gracefully - refresh list, inform user
throw new IllegalArgumentException("Favorite not found: " + favoriteId);
} Prevention
- Verify the favorite ID exists before performing delete or reorder operations.
- Refresh the favorites list in the UI if a not-found error occurs.
- Avoid caching favorite IDs across sessions as they may be deleted.
When it happens
Trigger: Calling any operation that invokes checkUserOperatePermission (adjustFavoriteToFirst, delete, etc.) with a favorite ID that the repository cannot find, resulting in a null Favorite passed to the permission check.
Common situations: Attempting to delete or reorder a favorite that was already removed; stale client-side cache referencing a deleted favorite; favorite ID typo; concurrent deletion by another session or admin cleanup.
Related errors
- add favorite fail. because favorite's user is not current lo
- user id and app id can't be empty at the same time
- can not operate other person's favorite
- Namespace's branch not exist. AppId = %s, ClusterName = %s,
- create namespace failed for: %s
AI-assisted analysis of apolloconfig/apollo@d95fc18d11 (2026-08-14).
Data as JSON: /api/errors/189ebddd976be6d9.
Report an issue: GitHub.