Sean-Walker0 opened a new pull request, #7526:
URL: https://github.com/apache/shenyu/pull/7526
## Modifications
`NamespacePluginServiceImpl#update` loaded the relation by id
(`namespacePluginRelMapper.selectById`) and wrote the DTO over it without
comparing namespaces, so a request carrying another namespace's `namespaceId`
could rewrite the relation (config / enabled / sort) — and, because the
replacement row is rebuilt from the DTO, even **move the relation into a
different namespace**.
The loaded relation is now validated before any write, using the `Assert`
style of the sibling `create` path:
```java
Assert.notNull(before, "Namespace plugin relation does not exist: " +
namespacePluginDTO.getId());
Assert.isTrue(Objects.equals(before.getNamespaceId(),
namespacePluginDTO.getNamespaceId()),
"Namespace plugin relation does not belong to namespace: " +
namespacePluginDTO.getNamespaceId());
```
Both failures reject the update with `ValidFailException` inside the
`@Transactional` boundary. Part of the same namespace-consistency family as
#7514 (create/update of proxy selector discovery) and #7524/#7525 (batch enable
scoping), which started from the review follow-up on #7514.
## Verifying this change
- [x] New `NamespacePluginServiceTest` cases:
`testUpdateRejectsRelationFromAnotherNamespace` and
`testUpdateRejectsUnknownRelation` — both red on the pre-fix code (the update
proceeded and returned `UPDATE_SUCCESS`), green after;
`testUpdateAcceptsRelationFromSameNamespace` guards the success path including
the published `onUpdated(now, before)` event.
- [x] `./mvnw -pl shenyu-admin -am test -B
-Dtest=NamespacePluginServiceTest` — 8/8 green (5 pre-existing cases
unchanged), module checkstyle clean.
## Notes
- Behavior change: an update whose DTO namespace does not match the stored
relation now fails instead of silently rewriting/moving the relation; the
previously unhandled missing-relation case (`selectById == null`) now fails
cleanly instead of proceeding with a `null` before-state.
- Orthogonality: #7512 (open) touches other methods of this class
(agent-gateway MCP tool aggregation); its diff was compared line by line — the
`update` method appears only as unchanged context, so the hunks do not overlap.
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [x] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true` (module-scoped: `shenyu-admin` targeted test class +
checkstyle green; full-module suite left to CI as with the other admin PRs).
--
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]