Aias00 opened a new issue, #6518:
URL: https://github.com/apache/shenyu/issues/6518

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/shenyu/issues) and found no similar issues.
   
   ### Apache ShenYu Component
   
   shenyu-admin
   
   ### What happened
   
   `ApiServiceImpl.update(...)` only refreshes tag relations when 
`apiDTO.getTagIds()` is not empty:
   
   ```java
   if (updateRows > 0) {
       if (CollectionUtils.isNotEmpty(apiDTO.getTagIds())) {
           List<String> tagIds = apiDTO.getTagIds();
           ...
           tagRelationMapper.deleteByApiId(apiDO.getId());
           tagRelationMapper.batchInsert(tags);
       }
   }
   ```
   
   This means an API that already has tags cannot be updated to have no tags. 
If the update request sends `tagIds: []`, the condition is false, so 
`deleteByApiId(...)` is skipped and the old `tag_relation` rows remain in the 
database.
   
   The API update succeeds, but later queries/filtering still see the previous 
tags.
   
   ### Expected behavior
   
   An explicit empty tag list should clear existing API tag relations. If 
`null` is intended to mean "do not change tags", it should be handled 
separately from an empty list. The current logic treats both `null` and `[]` as 
"leave old tags untouched".
   
   ### How to reproduce
   
   1. Create an API and associate one or more tags.
   2. Update the same API with `tagIds` set to an empty list:
   
   ```json
   {
     "id": "<api-id>",
     "tagIds": []
   }
   ```
   
   3. The update returns success.
   4. Query the API or inspect `tag_relation` rows for that API.
   5. The old tag relations are still present because `deleteByApiId(...)` only 
runs when `tagIds` is non-empty.
   
   ### Debug logs
   
   _No response_
   
   ### Environment
   
   Current `master` branch.
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to