fix: clear stale tag relations when updating an API with empty tags (#6518) - #6948
Open
yykaue wants to merge 2 commits into
Open
fix: clear stale tag relations when updating an API with empty tags (#6518)#6948yykaue wants to merge 2 commits into
yykaue wants to merge 2 commits into
Conversation
… empty and skip processing when null
Aias00
approved these changes
Aug 22, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
PR #6948 Review — fix: clear stale tag relations when updating an API with empty tags (#6518)
Verdict: APPROVE
Scope
shenyu-admin ApiServiceImpl.update: fix stale tag_relation rows when an API is updated with
an explicit empty tagIds list.
Verification
- Bug: original
if (CollectionUtils.isNotEmpty(apiDTO.getTagIds()))skipped the whole block for
an empty list, leaving stale tag relations untouched. - Fix: guard on
Objects.nonNull(apiDTO.getTagIds())(head file L24 importsjava.util.Objects)
→ alwaysdeleteByApiId(...); then re-insert only when non-empty. Semantics:null= leave
relations unchanged (preserved), empty list = clear, non-empty = replace. Exactly the intended
behavior. tagRelationMapper.deleteByApiId/batchInsertare existing methods (unchanged).- Tests added:
testUpdateWithEmptyTagIdsClearsRelationsassertsdeleteByApiIdinvoked and
batchInsertnever;testUpdateWithNullTagIdsKeepsRelationsasserts neither called.
Notes
- Correct, minimal bug fix with solid regression coverage. Approving.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR for?
Fixes #6518.
This PR fixes stale API tag relations when an API is updated with an explicit empty
tagIdslist.Changes
tagIdsis an empty list.nullmeans the API tag relations should not be changed.nulltag lists.Verification
ApiServiceTest: 8 tests passed.@Aias00 Could you please help review this PR? Thank you!