{"record":{"id":"9bfa679b4c227518","repo":"apache/incubator-seata","slug":"not-support-atomic-operation-putconfigifabsent-9bfa67","errorCode":null,"errorMessage":"not support atomic operation putConfigIfAbsent","messagePattern":"not support atomic operation putConfigIfAbsent","errorType":"exception","errorClass":"NotSupportYetException","httpStatus":null,"severity":"warning","filePath":"config/seata-config-nacos/src/main/java/org/apache/seata/config/nacos/NacosConfiguration.java","lineNumber":137,"sourceCode":"    @Override\n    public boolean putConfig(String dataId, String content, long timeoutMills) {\n        boolean result = false;\n        try {\n            if (!seataConfig.isEmpty()) {\n                seataConfig.setProperty(dataId, content);\n                result = configService.publishConfig(getNacosDataId(), getNacosGroup(), getSeataConfigStr());\n            } else {\n                result = configService.publishConfig(dataId, getNacosGroup(), content);\n            }\n        } catch (NacosException exx) {\n            LOGGER.error(exx.getErrMsg());\n        }\n        return result;\n    }\n\n    @Override\n    public boolean putConfigIfAbsent(String dataId, String content, long timeoutMills) {\n        throw new NotSupportYetException(\"not support atomic operation putConfigIfAbsent\");\n    }\n\n    @Override\n    public boolean removeConfig(String dataId, long timeoutMills) {\n        boolean result = false;\n        try {\n            if (!seataConfig.isEmpty()) {\n                seataConfig.remove(dataId);\n                result = configService.publishConfig(getNacosDataId(), getNacosGroup(), getSeataConfigStr());\n            } else {\n                result = configService.removeConfig(dataId, getNacosGroup());\n            }\n        } catch (NacosException exx) {\n            LOGGER.error(exx.getErrMsg());\n        }\n        return result;\n    }\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/config/seata-config-nacos/src/main/java/org/apache/seata/config/nacos/NacosConfiguration.java#L119-L155","documentation":"NacosConfiguration.putConfigIfAbsent unconditionally throws NotSupportYetException because Nacos's publishConfig API has no atomic create-if-absent semantics — a publish always overwrites. Seata surfaces this rather than silently faking atomicity when a caller requests the put-if-absent contract (used e.g. by config-center migration/CLUSTER operations).","triggerScenarios":"Calling Configuration.putConfigIfAbsent(dataId, content, timeoutMills) (directly or via Seata ops tooling that imports/migrates config into Nacos as the target config store).","commonSituations":"Running a config import/migration tool or console operation that assumes all backends support atomic put-if-absent, against a Nacos-backed seata-server configuration.","solutions":["Check support before calling: NacosConfiguration does not implement putConfigIfAbsent — use putConfig and handle idempotency yourself","Pre-check existence with getConfig(dataId, timeoutMills) and only publish when absent (accepting the non-atomic race window)","Catch NotSupportYetException and fall back to putConfig for backends without atomic create","If atomicity is mandatory, use a backend that supports it (e.g. Zookeeper/etcd-style CAS) instead of Nacos"],"exampleFix":"// before\nboolean created = configuration.putConfigIfAbsent(dataId, content, timeout);\n\n// after\nif (configuration.getConfig(dataId, timeout) == null) {\n    configuration.putConfig(dataId, content, timeout);\n}","handlingStrategy":"fallback","validationCode":"if (configuration instanceof NacosConfiguration) { /* avoid putConfigIfAbsent; check-then-put */ }","typeGuard":"boolean supportsPutIfAbsent(Configuration c) { try { return !(c instanceof NacosConfiguration); } catch (Exception e) { return false; } }","tryCatchPattern":"try { configuration.putConfigIfAbsent(id, content, timeout); } catch (NotSupportYetException e) { if (configuration.getConfig(id, timeout) == null) configuration.putConfig(id, content, timeout); }","preventionTips":["Check the backend implementation before requesting atomic ops","Wrap config import tooling with a capability matrix per backend","Accept that Nacos publish is last-writer-wins for migration flows"],"tags":["seata","nacos","config-center","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}