{"record":{"id":"ccdde2f4dbd3507f","repo":"alibaba/nacos","slug":"20004-ccdde2","errorCode":"20004","errorMessage":"certain config history for nid = %s not exist","messagePattern":"certain config history for nid = (.+?) not exist","errorType":"http","errorClass":"NacosApiException","httpStatus":404,"severity":"error","filePath":"config/src/main/java/com/alibaba/nacos/config/server/controller/v3/HistoryControllerV3.java","lineNumber":121,"sourceCode":"     */\n    @Since(\"3.0.0\")\n    @GetMapping\n    @Secured(action = ActionTypes.READ, signType = SignType.CONFIG, apiType = ApiType.ADMIN_API)\n    public Result<ConfigHistoryDetailInfo> getConfigHistoryInfo(ConfigFormV3 configForm,\n        @RequestParam(\"nid\") Long nid)\n        throws AccessException, NacosApiException {\n        ConfigHistoryInfo configHistoryInfo;\n        configForm.validate();\n        String dataId = configForm.getDataId();\n        String groupName = configForm.getGroupName();\n        String namespaceId = NamespaceUtil.processNamespaceParameter(configForm.getNamespaceId());\n        try {\n            //fix issue #9783\n            namespaceId = NamespaceUtil.processNamespaceParameter(namespaceId);\n            configHistoryInfo =\n                historyService.getConfigHistoryInfo(dataId, groupName, namespaceId, nid);\n        } catch (DataAccessException e) {\n            throw new NacosApiException(HttpStatus.NOT_FOUND.value(), ErrorCode.RESOURCE_NOT_FOUND,\n                \"certain config history for nid = \" + nid + \" not exist\");\n        }\n        return Result.success(ResponseUtil.transferToConfigHistoryDetailInfo(configHistoryInfo));\n    }\n    \n    /**\n     * Query previous config history information.\n     */\n    @Since(\"3.0.0\")\n    @GetMapping(value = \"/previous\")\n    @Secured(action = ActionTypes.READ, signType = SignType.CONFIG, apiType = ApiType.ADMIN_API)\n    public Result<ConfigHistoryDetailInfo> getPreviousConfigHistoryInfo(ConfigFormV3 configForm,\n        @RequestParam(\"id\") Long id) throws AccessException, NacosApiException {\n        ConfigHistoryInfo configHistoryInfo;\n        configForm.validate();\n        String dataId = configForm.getDataId();\n        String groupName = configForm.getGroupName();\n        String namespaceId = NamespaceUtil.processNamespaceParameter(configForm.getNamespaceId());","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/config/src/main/java/com/alibaba/nacos/config/server/controller/v3/HistoryControllerV3.java#L103-L139","documentation":"Thrown by GET /v3/admin/cs/config/history when the config history record for the given nid (history id) does not exist or the database lookup throws a DataAccessException. Returns HTTP 404 code 20004 (RESOURCE_NOT_FOUND). The nid must correspond to an actual persisted history entry.","triggerScenarios":"Requesting history detail with a nid that was never created, was purged by history retention policies, or belongs to a different dataId/group/namespace combination. Also raised when the underlying DB throws DataAccessException (connection failure, table missing).","commonSituations":"History was cleaned by retention limits; querying with wrong dataId/group for that nid; DB connectivity issues masquerading as not-found; migration where history table is empty.","solutions":["List history entries first (GET /v3/admin/cs/config/history/list) to obtain valid nids.","Verify dataId, group, and namespaceId match the config that owns that history nid.","Check DB connectivity and that the config_history table is populated; increase history retention if entries are being purged too fast."],"exampleFix":"// before\nGET /v3/admin/cs/config/history?dataId=app&groupName=G&nid=999999\n// after\n// fetch valid nid from the history list endpoint\nList<ConfigHistoryInfo> items = historyService.listHistory(dataId, group, ns, pageNo, pageSize);\nLong validNid = items.get(0).getId();\nGET /v3/admin/cs/config/history?dataId=app&groupName=G&nid=<validNid>","handlingStrategy":"try-catch","validationCode":"// Fetch a valid nid from the history list before detail query\nPage<ConfigHistoryInfo> page = historyApi.listHistory(dataId, group, ns, 1, 10);\nif (page.getPageItems().isEmpty()) { /* no history at all */ return; }\nLong nid = page.getPageItems().get(0).getId();","typeGuard":null,"tryCatchPattern":"try { historyApi.getHistoryDetail(dataId, group, ns, nid); }\ncatch (NacosApiException e) {\n    if (e.getErrCode() == NacosException.NOT_FOUND)\n        { /* nid invalid or purged — re-list */ } else throw e;\n}","preventionTips":["Always obtain nid from the history list endpoint.","Check DB connectivity if DataAccessException is the root cause."],"tags":["config","history","resource-not-found","database"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}