apache / apache/shenyu

[BUG] URIRegisterExecutorSubscriber registers an entire batch under the first namespace's namespaceId, mis-routing cross-namespace URIs

Open Beginner friendly
#6,546 1 comment 0 reactions 0 assignees View on GitHub
admin priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
Within a selector group (grouped by `contextPath` or `appName` in `buildData`), the URIs are split only by `EventType`. For each resulting list, the code picks **one** namespace via `findFirst()`: `register.stream().map(URIRegisterDTO::getNamespaceId).filter(...isNotBlank).findFirst().ifPresent(namespaceId -> service.registerURI(selectorName, register, namespaceId))`. Every URI in `register` is then registered under that single namespaceId, ignoring each DTO's own `namespaceId`. The same pattern is used for `heartbeat` and `offline`.

## Location
```
shenyu-admin/.../disruptor/subscriber/URIRegisterExecutorSubscriber.java:88-105
```

## Impact
Two namespaces share the same `contextPath`/`appName` and a published batch contains URIs from both namespaces -> cross-namespace URI mis-registration: URIs belonging to namespace B are recorded under namespace A, leading to routing/selectors being created in the wrong namespace. `offline` is especially dangerous — taking a backend offline in the wrong namespace while leaving it "online" in the correct one. `RegisterServerConsumerExecutor.isValidData` only checks that each URI's `namespaceId` is non-blank — it does not enforce uniformity.

## Suggested fix
Sub-group by `namespaceId` before dispatching: `uriList.stream().collect(Collectors.groupingBy(URIRegisterDTO::getNamespaceId))` and call `service.registerURI/heartbeat/offline` once per `(namespaceId, subList)`.

## Related existing issue(s)
None

_Identified during the 2026-08-02 audit; full list in [`docs/issue-candidates-2026-08-02.md`](docs/issue-candidates-2026-08-02.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Read shenyu-admin/.../disruptor/subscriber/URIRegisterExecutorSubscriber.java:88-105, focusing on how URI lists are grouped before register, heartbeat, and offline dispatch. Verify the change against RegisterServerConsumerExecutor.isValidData and confirm that each operation dispatches every URI with its own namespaceId rather than mixing namespaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.