elastic/elasticsearch · error · ResourceNotFoundException

Data stream [{}] not found

Error message

Data stream [{}] not found

What it means

Thrown by validateDataStream in TransportPastTimeSeriesIndexCreationAction when the named data stream does not exist in the current project metadata. It is a ResourceNotFoundException surfaced before any further validation of mode/replicated/system status.

Source

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

            return sortedTimeWindows;
        }

        public void init() {
            clusterService.getClusterSettings()
                .addSettingsUpdateConsumer(PAST_TSDB_INDEX_INTERVAL, tv -> indexIntervalMillis = tv.millis());
        }
    }

    record CoveredTimeWindow(long start, long end) {

        CoveredTimeWindow(Instant start, Instant end) {
            this(start.toEpochMilli(), end.toEpochMilli());
        }
    }

    private static void validateDataStream(String dataStreamName, DataStream dataStream, ProjectMetadata project) {
        if (dataStream == null) {
            throw new ResourceNotFoundException("Data stream [" + dataStreamName + "] not found");
        }
        if (dataStream.isReplicated()) {
            throw new IllegalArgumentException("Cannot create past TSDB backing index for replicated data stream [" + dataStreamName + "]");
        }
        if (dataStream.isSystem()) {
            throw new IllegalArgumentException("Cannot create past TSDB backing index for system data stream [" + dataStreamName + "]");
        }

        if (IndexMode.isTsdb(dataStream.getIndexMode()) == false) {
            throw new IllegalArgumentException(
                "Cannot create past TSDB backing index for data stream ["
                    + dataStreamName
                    + "] with mode ["
                    + dataStream.getIndexMode()
                    + "], it needs to be a time series data stream."
            );
        }
        Index writeIndex = dataStream.getWriteIndex();

View on GitHub (pinned to db6a809a66)

Solutions

  1. Verify the data stream exists with GET _data_stream/<name> in the same project.
  2. Correct the name in the request to match an existing stream.
  3. If restored/renamed, use the new name.
Defensive patterns

Strategy: validation

Validate before calling

DataStream ds = project.metadata().dataStreams().get(dataStreamName);
if (ds == null) {
  throw new ResourceNotFoundException("Data stream [" + dataStreamName + "] not found");
}

Prevention

When it happens

Trigger: Calling the past TSDB index creation task with a data stream name that resolves to null in projectState.metadata().dataStreams(). Wrong project context, typo, or a stream that was never created.

Common situations: Cross-project request routed to the wrong project; typo in the data stream name; stream deleted between task enqueue and execution; restore that renamed the stream.

Related errors


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