risingwavelabs/risingwave · error · SinkError

Cannot find '{option_name}',please set it.

Error message

Cannot find '{option_name}',please set it.

What it means

The Redis sink in RisingWave builds a TemplateEncoder from the sink's WITH options, and for `redis_value_type = 'string'` it requires a template option: `key_format` when the sink has a primary key, otherwise `value_format`. The option named in the message was absent from `format_desc.options`, so the sink fails during connector build with a SinkError::Config.

Source

Thrown at src/connector/src/sink/formatter/mod.rs:326

        )
    }
}

impl EncoderBuild for TemplateEncoder {
    async fn build(b: EncoderParams<'_>, pk_indices: Option<Vec<usize>>) -> Result<Self> {
        let redis_value_type = b
            .format_desc
            .options
            .get(REDIS_VALUE_TYPE)
            .map_or(REDIS_VALUE_TYPE_STRING, |s| s.as_str());
        match redis_value_type {
            REDIS_VALUE_TYPE_STRING => {
                let option_name = match pk_indices {
                    Some(_) => KEY_FORMAT,
                    None => VALUE_FORMAT,
                };
                let template = b.format_desc.options.get(option_name).ok_or_else(|| {
                    SinkError::Config(anyhow!("Cannot find '{option_name}',please set it."))
                })?;
                Ok(TemplateEncoder::new_string(
                    b.schema,
                    pk_indices,
                    template.clone(),
                ))
            }
            REDIS_VALUE_TYPE_GEO => match pk_indices {
                Some(_) => {
                    let member_name = b.format_desc.options.get(MEMBER_NAME).ok_or_else(|| {
                        SinkError::Config(anyhow!("Cannot find `{MEMBER_NAME}`,please set it."))
                    })?;
                    let template = b.format_desc.options.get(KEY_FORMAT).ok_or_else(|| {
                        SinkError::Config(anyhow!("Cannot find `{KEY_FORMAT}`,please set it."))
                    })?;
                    TemplateEncoder::new_geo_key(
                        b.schema,
                        pk_indices,

View on GitHub (pinned to 6469eb736d)

Solutions

  1. Determine whether your sink has a primary key: if yes add `key_format`, if no add `value_format` to the WITH options.
  2. Provide the missing template string, e.g. `key_format = '%s:id'` or `value_format = '{"id": %s}'`, using RisingWave template placeholders for columns.
  3. Check for typos in the option name — it must be exactly `key_format` or `value_format`, not `keyformat`/`key-format`.

Example fix

// before
CREATE SINK s FROM mv INTO redis WITH (
  connector = 'redis',
  redis.url = 'redis://127.0.0.1:6379',
  redis_value_type = 'string'
);
// after
CREATE SINK s FROM mv INTO redis WITH (
  connector = 'redis',
  redis.url = 'redis://127.0.0.1:6379',
  redis_value_type = 'string',
  key_format = '%s'   -- table has a primary key; use value_format if it does not
);
Defensive patterns

Strategy: validation

Validate before calling

let has_pk = <sink_has_primary_key>;
let required = if has_pk { "key_format" } else { "value_format" };
if !with_options.contains_key(required) {
    return Err(format!("Redis string sink requires `{}` in WITH options", required));
}

Type guard

fn has_option(opts: &HashMap<String, String>, key: &str) -> bool {
    opts.get(key).map(|v| !v.trim().is_empty()).unwrap_or(false)
}

Try / catch

match sink_build_result {
    Err(e) if e.to_string().contains("please set it") => {
        eprintln!("Redis sink misconfigured: {}", e); // add key_format/value_format and retry DDL
    }
    other => other?,
}

Prevention

When it happens

Trigger: Creating a Redis sink with `redis_value_type = 'string'` (the default) but omitting the required template option: no `key_format` when the sink defines a primary key, or no `value_format` when it does not.

Common situations: Users write `WITH (connector='redis', redis.url='...', redis_value_type='string')` and forget the format template; or they set `value_format` but their table has a primary key so the code actually looks up `key_format` (or vice versa).

Understand the failure class

Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.

Related errors


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