shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[BUG] Eureka incremental upstream updates are filtered for non-default namespaces

Open sunnysabor opened this issue 3 months ago • 1 comments

Is there an existing issue for this?

I have searched the existing issues.

Current Behavior

When the same Eureka service is configured as a discovery listener node in a non-default ShenYu namespace, the initial discovery refresh can populate upstreams with the correct namespace, but subsequent Eureka incremental events may be filtered out.

The incremental event path currently has a namespace mismatch risk:

  • EurekaInstanceRegisterRepository.buildUpstreamJsonFromInstance(...) builds upstream JSON with url, weight, protocol, props, and status, but no namespaceId.
  • DiscoveryDataChangedEventSyncListener.buildProxySelectorData(...) parses that JSON. When DiscoveryUpstreamData.namespaceId is blank, it defaults the upstream to SYS_DEFAULT_NAMESPACE_ID.
  • The listener then filters upstreams by discoverySyncData.getNamespaceId().

For a non-default namespace, a blank upstream namespace is converted to the default namespace and then filtered out.

Expected Behavior

When a registry event payload does not include a ShenYu namespace, the upstream should inherit the namespace of the current discovery sync context, i.e. discoverySyncData.getNamespaceId().

This is consistent with AbstractDiscoveryProcessor.fetchAll(...), which fills missing upstream namespaces from proxySelectorDTO.getNamespaceId() during the full refresh path.

Payloads that explicitly include namespaceId should keep the current filtering behavior.

Steps To Reproduce

  1. Configure at least two ShenYu namespaces, including one non-default namespace.
  2. In the non-default namespace, configure a divide discovery selector with discoveryType=eureka and listenerNode equal to an Eureka application name.
  3. Ensure the initial full discovery refresh populates upstream data for that selector.
  4. Add, remove, or update an Eureka instance for that application.
  5. Observe that the incremental upstream event payload has no namespaceId, is defaulted to SYS_DEFAULT_NAMESPACE_ID, and is filtered out for the non-default namespace.

Environment

ShenYu version(s): current master

Debug logs

Relevant code paths:

  • org.apache.shenyu.registry.eureka.EurekaInstanceRegisterRepository#buildUpstreamJsonFromInstance
  • org.apache.shenyu.admin.discovery.DiscoveryDataChangedEventSyncListener#buildProxySelectorData
  • org.apache.shenyu.admin.discovery.AbstractDiscoveryProcessor#fetchAll

Anything else?

The minimal behavior-preserving fix is to fill missing upstream namespaces from the current discovery sync context:

if (StringUtils.isBlank(discoveryUpstreamData.getNamespaceId())) {
    discoveryUpstreamData.setNamespaceId(discoverySyncData.getNamespaceId());
}

This preserves behavior for payloads that explicitly include namespaceId, while making blank namespace handling consistent with the full refresh path.

sunnysabor avatar Aug 12 '26 08:08 sunnysabor

👋 Hello @Aias00

A new issue has been opened by @sunnysabor:

  • Title: [BUG] Eureka incremental upstream updates are filtered for non-default namespaces
  • Link: https://github.com/apache/shenyu/issues/6904

Please review when you have time. Thank you! 🙏

github-actions[bot] avatar Aug 12 '26 09:08 github-actions[bot]