alibaba/nacos · error · NacosApiException
20004
20004
Error message
certain config history for nid = %s not exist
What it means
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.
Source
Thrown at config/src/main/java/com/alibaba/nacos/config/server/controller/v3/HistoryControllerV3.java:121
*/
@Since("3.0.0")
@GetMapping
@Secured(action = ActionTypes.READ, signType = SignType.CONFIG, apiType = ApiType.ADMIN_API)
public Result<ConfigHistoryDetailInfo> getConfigHistoryInfo(ConfigFormV3 configForm,
@RequestParam("nid") Long nid)
throws AccessException, NacosApiException {
ConfigHistoryInfo configHistoryInfo;
configForm.validate();
String dataId = configForm.getDataId();
String groupName = configForm.getGroupName();
String namespaceId = NamespaceUtil.processNamespaceParameter(configForm.getNamespaceId());
try {
//fix issue #9783
namespaceId = NamespaceUtil.processNamespaceParameter(namespaceId);
configHistoryInfo =
historyService.getConfigHistoryInfo(dataId, groupName, namespaceId, nid);
} catch (DataAccessException e) {
throw new NacosApiException(HttpStatus.NOT_FOUND.value(), ErrorCode.RESOURCE_NOT_FOUND,
"certain config history for nid = " + nid + " not exist");
}
return Result.success(ResponseUtil.transferToConfigHistoryDetailInfo(configHistoryInfo));
}
/**
* Query previous config history information.
*/
@Since("3.0.0")
@GetMapping(value = "/previous")
@Secured(action = ActionTypes.READ, signType = SignType.CONFIG, apiType = ApiType.ADMIN_API)
public Result<ConfigHistoryDetailInfo> getPreviousConfigHistoryInfo(ConfigFormV3 configForm,
@RequestParam("id") Long id) throws AccessException, NacosApiException {
ConfigHistoryInfo configHistoryInfo;
configForm.validate();
String dataId = configForm.getDataId();
String groupName = configForm.getGroupName();
String namespaceId = NamespaceUtil.processNamespaceParameter(configForm.getNamespaceId());View on GitHub (pinned to 9b989acdf1)
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.
Example fix
// before GET /v3/admin/cs/config/history?dataId=app&groupName=G&nid=999999 // after // fetch valid nid from the history list endpoint List<ConfigHistoryInfo> items = historyService.listHistory(dataId, group, ns, pageNo, pageSize); Long validNid = items.get(0).getId(); GET /v3/admin/cs/config/history?dataId=app&groupName=G&nid=<validNid>
Defensive patterns
Strategy: try-catch
Validate before calling
// Fetch a valid nid from the history list before detail query
Page<ConfigHistoryInfo> page = historyApi.listHistory(dataId, group, ns, 1, 10);
if (page.getPageItems().isEmpty()) { /* no history at all */ return; }
Long nid = page.getPageItems().get(0).getId(); Try / catch
try { historyApi.getHistoryDetail(dataId, group, ns, nid); }
catch (NacosApiException e) {
if (e.getErrCode() == NacosException.NOT_FOUND)
{ /* nid invalid or purged — re-list */ } else throw e;
} Prevention
- Always obtain nid from the history list endpoint.
- Check DB connectivity if DataAccessException is the root cause.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/ccdde2f4dbd3507f.
Report an issue: GitHub.