risingwavelabs/risingwave · error · ConnectorError

stream {} not found, set `allow_create_stream` to true to cr

Error message

stream {} not found, set `allow_create_stream` to true to create a stream

What it means

Thrown by `build_or_get_stream` in the NATS JetStream connector. When a NAT JetStream stream with the requested name cannot be fetched, and the source options have not set `allow_create_stream` to true, the connector refuses to auto-create the stream and returns this error. It protects users from unintentionally creating streams on the NATS server.

Source

Thrown at src/connector/src/connector_common/common.rs:1228

        &self,
        jetstream: jetstream::Context,
        stream_str: String,
    ) -> ConnectorResult<jetstream::stream::Stream> {
        let subjects: Vec<String> = self.subject.split(',').map(|s| s.to_owned()).collect();

        // In `SourceEnumerator`, we may create a stream
        // In `SourceReader`, the desired stream MUST exist
        if let Ok(mut stream_instance) = jetstream.get_stream(&stream_str).await {
            tracing::info!(
                "load existing nats stream ({:?}) with config {:?}",
                stream_str,
                stream_instance.info().await?
            );
            return Ok(stream_instance);
        }

        if !self.allow_create_stream {
            return Err(anyhow!(
                "stream {} not found, set `allow_create_stream` to true to create a stream",
                stream_str
            )
            .into());
        }

        let mut config = jetstream::stream::Config {
            name: stream_str.clone(),
            max_bytes: 1000000,
            subjects,
            ..Default::default()
        };
        if let Some(v) = self.max_bytes {
            config.max_bytes = v;
        }
        if let Some(v) = self.max_messages {
            config.max_messages = v;
        }

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Set the source option `allow_create_stream = true` so the connector may create the stream.
  2. Verify the stream exists on the NATS server (e.g. `nats stream info <name>`) and fix any typo in the stream name option.
  3. Point the connector at the correct NATS URL/account where the stream actually lives.
  4. Pre-create the JetStream stream manually with the expected name and subjects.

Example fix

// before
CREATE SOURCE nats_src WITH (connector='nats', stream='orders', subject='orders.*');
// after
CREATE SOURCE nats_src WITH (connector='nats', stream='orders', subject='orders.*', allow_create_stream=true);
Defensive patterns

Strategy: validation

Validate before calling

// before creating the source, check the stream exists or the flag is set
let stream_exists = jetstream.get_stream(&stream_name).await.is_ok();
if !stream_exists && options.get("allow_create_stream").map(|v| v != "true").unwrap_or(true) {
    return Err(format!("stream {} not found; set allow_create_stream=true or create it first", stream_name));
}

Try / catch

match source.create().await {
    Err(e) if e.to_string().contains("set `allow_create_stream` to true") => {
        // surface a hint: either enable the flag or pre-create the JetStream stream
    }
    Err(e) => return Err(e),
    Ok(src) => Ok(src),
}

Prevention

When it happens

Trigger: Calling build_or_get_stream (e.g. from a SourceReader) where `jetstream.get_stream(stream_str)` fails because the stream does not exist on the NATS server, and the option `allow_create_stream` is not enabled in the source properties.

Common situations: Typo in the stream name in the CREATE SOURCE/SINK options; the stream was deleted or exists on a different NATS server/JetStream account; running a reader against a stream the enumerator was supposed to create but did not; forgetting the `allow_create_stream=true` option on a fresh NATS setup.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/c2e8025204f55790. Report an issue: GitHub.