{"record":{"id":"062897835590e020","repo":"elastic/elasticsearch","slug":"data-stream-does-not-exist","errorCode":null,"errorMessage":"data stream [{}] does not exist","messagePattern":"data stream \\[(.+?)\\] does not exist","errorType":"http","errorClass":"ResourceNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportPromoteDataStreamAction.java","lineNumber":111,"sourceCode":"\n                @Override\n                public void clusterStateProcessed(ClusterState oldState, ClusterState newState) {\n                    listener.onResponse(AcknowledgedResponse.TRUE);\n                }\n            }\n        );\n    }\n\n    @SuppressForbidden(reason = \"legacy usage of unbatched task\") // TODO add support for batching here\n    private void submitUnbatchedTask(@SuppressWarnings(\"SameParameterValue\") String source, ClusterStateUpdateTask task) {\n        clusterService.submitUnbatchedStateUpdateTask(source, task);\n    }\n\n    static ProjectMetadata promoteDataStream(ProjectMetadata project, PromoteDataStreamAction.Request request) {\n        DataStream dataStream = project.dataStreams().get(request.getName());\n\n        if (dataStream == null) {\n            throw new ResourceNotFoundException(\"data stream [\" + request.getName() + \"] does not exist\");\n        }\n\n        warnIfTemplateMissingForDatastream(dataStream, project);\n\n        DataStream promotedDataStream = dataStream.promoteDataStream();\n        return ProjectMetadata.builder(project).put(promotedDataStream).build();\n    }\n\n    private static void warnIfTemplateMissingForDatastream(DataStream dataStream, ProjectMetadata project) {\n        var datastreamName = dataStream.getName();\n\n        var matchingIndex = project.templatesV2()\n            .values()\n            .stream()\n            .filter(cit -> cit.getDataStreamTemplate() != null)\n            .flatMap(cit -> cit.indexPatterns().stream())\n            .anyMatch(pattern -> Regex.simpleMatch(pattern, datastreamName));\n","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportPromoteDataStreamAction.java#L93-L129","documentation":"ResourceNotFoundException from promoteDataStream when project.dataStreams().get(name) returns null. The promote operation (converts a stand-in/replicated stream into a regular one) requires the stream to already exist in the project metadata.","triggerScenarios":"POST _data_stream/<name>/_promote (PromoteDataStreamAction) where <name> is not present in the cluster's data stream metadata. The static promoteDataStream method is invoked after the request is dispatched and it fails fast on the null lookup.","commonSituations":"Typo in the data stream name; promoting on the wrong cluster/project; the stream was deleted between the lookup and the call; cross-cluster replication follower where the stream lives on the leader only.","solutions":["List streams with GET _data_stream to get the exact name","Confirm you are connected to the cluster/project that owns the stream","Create the data stream first if promotion of a brand-new stream was intended"],"exampleFix":"// before\nPOST _data_stream/mylog/_promote   // name typo\n// after\nGET _data_stream/my-logs*            // find real name\nPOST _data_stream/my-logs/_promote","handlingStrategy":"validation","validationCode":"// Resolve the stream existence before promoting:\nif (!dataStreamExists(name)) {\n    throw new ResourceNotFoundException(\"data stream \" + name + \" does not exist\");\n}\npromoteDataStream(name);","typeGuard":null,"tryCatchPattern":"try { promoteDataStream(name); }\ncatch (ResourceNotFoundException e) { /* list streams, surface actionable error to caller */ }","preventionTips":["Cache the list of data stream names and validate inputs against it","Use deterministic naming so promotion targets are unambiguous","Run promotion against the leader cluster, not a follower"],"tags":["data-streams","promote","not-found","rest"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}