apache/shenyu · error · ShenyuException

e.getMessage()

Error message

e.getMessage()

What it means

doPublishConfig serializes the given data to JSON and publishes it to Nacos under the given dataId and group. Any NacosException from the publish is logged and rethrown as ShenyuException(e.getMessage()), so a failed config push aborts with the Nacos client's error text.

Solutions

  1. Verify Nacos connectivity and server-addr/namespace/group settings.
  2. Retry the publish from the dashboard once Nacos is healthy; transient timeouts are common.
  3. Check Nacos server logs for write failures (e.g. disk full, Raft leader loss).
  4. Inspect the wrapped message for the exact NacosException cause (e.g. errCode 400/403/503).

Example fix

// before
throw new ShenyuException(e.getMessage());
// after
catch (NacosException e) {
    throw new ShenyuException("Failed to publish dataId " + dataId + " to nacos", e);
}
Defensive patterns

Strategy: retry

Validate before calling

if (!nacosReachable(serverAddr, timeoutMs)) { throw new IllegalStateException("Cannot publish: Nacos unreachable"); }

Type guard

null

Try / catch

try { listener.doPublishConfig(dataId, data); } catch (ShenyuException e) { log.error("Nacos publish failed: {}", e.getMessage(), e); /* retry or requeue the config change */ }

Prevention

When it happens

Trigger: Publishing plugin/selector/rule/attribute config changes to Nacos while the Nacos server is down, unreachable, times out, or rejects the write (auth failure, oversized payload, invalid group).

Common situations: Editing a rule in the shenyu dashboard while the Nacos cluster is degraded, network partition between admin and Nacos, wrong namespace, or Nacos auth enabled without credentials.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/a43fc68c87d75741. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java:56

    public NacosDataChangedListener(final ConfigService configService) {
        super(new ChangeData(NacosPathConstants.PLUGIN_DATA_ID, NacosPathConstants.SELECTOR_DATA_ID,
                NacosPathConstants.RULE_DATA_ID, NacosPathConstants.AUTH_DATA_ID, NacosPathConstants.META_DATA_ID,
                NacosPathConstants.PROXY_SELECTOR_DATA_ID, NacosPathConstants.DISCOVERY_DATA_ID));
        this.configService = configService;
    }

    @Override
    public void doPublishConfig(final String dataId, final Object data) {
        try {
            configService.publishConfig(
                    dataId, 
                    NacosPathConstants.GROUP, 
                    GsonUtils.getInstance().toJson(data),
                    ConfigType.JSON.getType());
        } catch (NacosException e) {
            LOG.error("Publish data to nacos error.", e);
            throw new ShenyuException(e.getMessage());
        }
    }

    @Override
    public void doDelConfig(final String dataId) {
        try {
            configService.removeConfig(
                    dataId,
                    NacosPathConstants.GROUP);
        } catch (NacosException e) {
            LOG.error("Publish data to nacos error.", e);
            throw new ShenyuException(e.getMessage());
        }
    }

    @Override
    public String getConfig(final String dataId) {
        try {

View on GitHub (pinned to 567142e072)