elastic/elasticsearch · error · ResourceNotFoundException

data stream [{}] does not exist

Error message

data stream [{}] does not exist

What it means

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.

Source

Thrown at modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportPromoteDataStreamAction.java:111

                @Override
                public void clusterStateProcessed(ClusterState oldState, ClusterState newState) {
                    listener.onResponse(AcknowledgedResponse.TRUE);
                }
            }
        );
    }

    @SuppressForbidden(reason = "legacy usage of unbatched task") // TODO add support for batching here
    private void submitUnbatchedTask(@SuppressWarnings("SameParameterValue") String source, ClusterStateUpdateTask task) {
        clusterService.submitUnbatchedStateUpdateTask(source, task);
    }

    static ProjectMetadata promoteDataStream(ProjectMetadata project, PromoteDataStreamAction.Request request) {
        DataStream dataStream = project.dataStreams().get(request.getName());

        if (dataStream == null) {
            throw new ResourceNotFoundException("data stream [" + request.getName() + "] does not exist");
        }

        warnIfTemplateMissingForDatastream(dataStream, project);

        DataStream promotedDataStream = dataStream.promoteDataStream();
        return ProjectMetadata.builder(project).put(promotedDataStream).build();
    }

    private static void warnIfTemplateMissingForDatastream(DataStream dataStream, ProjectMetadata project) {
        var datastreamName = dataStream.getName();

        var matchingIndex = project.templatesV2()
            .values()
            .stream()
            .filter(cit -> cit.getDataStreamTemplate() != null)
            .flatMap(cit -> cit.indexPatterns().stream())
            .anyMatch(pattern -> Regex.simpleMatch(pattern, datastreamName));

View on GitHub (pinned to db6a809a66)

Solutions

  1. List streams with GET _data_stream to get the exact name
  2. Confirm you are connected to the cluster/project that owns the stream
  3. Create the data stream first if promotion of a brand-new stream was intended

Example fix

// before
POST _data_stream/mylog/_promote   // name typo
// after
GET _data_stream/my-logs*            // find real name
POST _data_stream/my-logs/_promote
Defensive patterns

Strategy: validation

Validate before calling

// Resolve the stream existence before promoting:
if (!dataStreamExists(name)) {
    throw new ResourceNotFoundException("data stream " + name + " does not exist");
}
promoteDataStream(name);

Try / catch

try { promoteDataStream(name); }
catch (ResourceNotFoundException e) { /* list streams, surface actionable error to caller */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/062897835590e020. Report an issue: GitHub.