[BUG] Discovery upstream batch deletion is not scoped to a namespace
Current behavior
The Admin endpoint DELETE /discovery-upstream/batch accepts only a list of upstream IDs. DiscoveryUpstreamServiceImpl.delete(ids) resolves rows with selectByIds(ids) and removes them with deleteByIds(ids); neither query includes namespace_id or checks the namespace of the owning discovery handler. The service then refreshes the affected handlers, so the deletion immediately changes their published upstream snapshots.
Unlike the delete API, the model and listing path are namespace-aware: upstream rows store namespace_id, and listAllDataByNamespaceId(namespaceId) filters on it. The batch-delete API therefore cannot enforce the namespace boundary represented by those rows. A caller operating in one namespace who submits an upstream ID from another namespace can delete that other namespace's endpoint entry.
Reproduction
- Create upstream rows in namespaces A and B, each associated with its own discovery handler.
- In a request made while working in namespace A, call
DELETE /discovery-upstream/batchwith the ID of the row from B. - The service selects and deletes the B row by ID, then calls
fetchAllfor B's handler; B's published upstream list changes.
The endpoint currently has no namespace parameter with which to scope the request.
Expected behavior
Scope batch deletion to the active/request namespace and verify that each ID belongs to both that namespace and its owning handler before deletion. IDs outside the namespace should be rejected or ignored without changing another namespace's upstream snapshot. Preserve the existing post-delete synchronization for rows that are validly deleted.
Source references
shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/DiscoveryUpstreamController.java:deleteDiscoveryUpstreamaccepts onlyList<String> ids.shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/DiscoveryUpstreamServiceImpl.java:deletecallsselectByIdsanddeleteByIds, then refreshes each affected handler.shenyu-admin/src/main/resources/mappers/discovery-upstream-sqlmap.xml: both mapper statements filter by ID only;selectByNamespaceIdexists separately.
This is a source-confirmed issue; I did not modify a live database or run an HTTP deployment. It affects a different resource and endpoint than selector deletion in #6826.