{"record":{"id":"a43fc68c87d75741","repo":"apache/shenyu","slug":"e-getmessage-nacosdatachangedlistener","errorCode":null,"errorMessage":"e.getMessage()","messagePattern":"e\\.getMessage\\(\\)","errorType":"exception","errorClass":"ShenyuException","httpStatus":null,"severity":"error","filePath":"shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java","lineNumber":56,"sourceCode":"\n    public NacosDataChangedListener(final ConfigService configService) {\n        super(new ChangeData(NacosPathConstants.PLUGIN_DATA_ID, NacosPathConstants.SELECTOR_DATA_ID,\n                NacosPathConstants.RULE_DATA_ID, NacosPathConstants.AUTH_DATA_ID, NacosPathConstants.META_DATA_ID,\n                NacosPathConstants.PROXY_SELECTOR_DATA_ID, NacosPathConstants.DISCOVERY_DATA_ID));\n        this.configService = configService;\n    }\n\n    @Override\n    public void doPublishConfig(final String dataId, final Object data) {\n        try {\n            configService.publishConfig(\n                    dataId, \n                    NacosPathConstants.GROUP, \n                    GsonUtils.getInstance().toJson(data),\n                    ConfigType.JSON.getType());\n        } catch (NacosException e) {\n            LOG.error(\"Publish data to nacos error.\", e);\n            throw new ShenyuException(e.getMessage());\n        }\n    }\n\n    @Override\n    public void doDelConfig(final String dataId) {\n        try {\n            configService.removeConfig(\n                    dataId,\n                    NacosPathConstants.GROUP);\n        } catch (NacosException e) {\n            LOG.error(\"Publish data to nacos error.\", e);\n            throw new ShenyuException(e.getMessage());\n        }\n    }\n\n    @Override\n    public String getConfig(final String dataId) {\n        try {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java#L38-L74","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify Nacos connectivity and server-addr/namespace/group settings.","Retry the publish from the dashboard once Nacos is healthy; transient timeouts are common.","Check Nacos server logs for write failures (e.g. disk full, Raft leader loss).","Inspect the wrapped message for the exact NacosException cause (e.g. errCode 400/403/503)."],"exampleFix":"// before\nthrow new ShenyuException(e.getMessage());\n// after\ncatch (NacosException e) {\n    throw new ShenyuException(\"Failed to publish dataId \" + dataId + \" to nacos\", e);\n}","handlingStrategy":"retry","validationCode":"if (!nacosReachable(serverAddr, timeoutMs)) { throw new IllegalStateException(\"Cannot publish: Nacos unreachable\"); }","typeGuard":"null","tryCatchPattern":"try { listener.doPublishConfig(dataId, data); } catch (ShenyuException e) { log.error(\"Nacos publish failed: {}\", e.getMessage(), e); /* retry or requeue the config change */ }","preventionTips":["Queue config-change events and retry on Nacos failures.","Monitor Nacos cluster health (Raft status, disk space).","Keep published payloads small enough for Nacos size limits.","Pin namespace/group values in configuration to avoid mismatches."],"tags":["nacos","config-sync","publish"],"backgroundTag":"api-error-response","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}