{"record":{"id":"bc333179b376a66c","repo":"risingwavelabs/risingwave","slug":"cannot-find-key-format-please-set-it-bc3331","errorCode":null,"errorMessage":"Cannot find '{KEY_FORMAT}',please set it.","messagePattern":"Cannot find '(.+?)',please set it\\.","errorType":"validation","errorClass":"SinkError","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/formatter/mod.rs","lineNumber":414,"sourceCode":"                            \"`{STREAM}` and `{STREAM_COLUMN}` only one can be set\"\n                        )));\n                    }\n                    TemplateEncoder::new_pubsub_stream_key(\n                        b.schema,\n                        pk_indices,\n                        stream,\n                        stream_column,\n                    )\n                }\n                None => {\n                    let value_template =\n                        b.format_desc.options.get(VALUE_FORMAT).ok_or_else(|| {\n                            SinkError::Config(anyhow!(\n                                \"Cannot find '{VALUE_FORMAT}',please set it.\"\n                            ))\n                        })?;\n                    let key_template = b.format_desc.options.get(KEY_FORMAT).ok_or_else(|| {\n                        SinkError::Config(anyhow!(\"Cannot find '{KEY_FORMAT}',please set it.\"))\n                    })?;\n\n                    Ok(TemplateEncoder::new_stream_value(\n                        b.schema,\n                        pk_indices,\n                        key_template.clone(),\n                        value_template.clone(),\n                    ))\n                }\n            },\n            _ => Err(SinkError::Config(anyhow!(\n                \"The value type {} is not supported\",\n                redis_value_type\n            ))),\n        }\n    }\n}\n","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/formatter/mod.rs#L396-L432","documentation":"For `redis_value_type = 'stream'` sinks WITHOUT a primary key, after `value_format` the builder requires the `key_format` option (the template for the stream key). A missing `key_format` aborts the sink build with this SinkError::Config.","triggerScenarios":"Creating a Redis stream sink without a primary key, providing `value_format` but not `key_format` in the WITH options.","commonSituations":"Users supply the value template only and overlook that stream sinks also need the key template, unlike `string` sinks without a primary key which need only `value_format`.","solutions":["Add `key_format = '<template>'` to the WITH options.","Keep `value_format` set as well — both templates are required together in this branch.","Ensure the stream target option (`stream` or `stream_column`) matches the table's primary key situation."],"exampleFix":"// before\nWITH (redis_value_type='stream', stream='events', value_format='{\"v\": %s}');\n// after\nWITH (redis_value_type='stream', stream='events', value_format='{\"v\": %s}', key_format='%s');","handlingStrategy":"validation","validationCode":"if value_type == \"stream\" && !has_pk && !with_options.contains_key(\"key_format\") {\n    return Err(\"PK-less Redis stream sink requires `key_format`\".into());\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"`key_format`\") => {\n        eprintln!(\"Add `key_format = '<template>'` to WITH options: {}\", e);\n    }\n    other => other?,\n}","preventionTips":["Treat key_format + value_format as a required pair for stream sinks","Verify option spelling exactly","Document the required WITH options in team runbooks for Redis sinks"],"tags":["redis","sink","stream","configuration"],"backgroundTag":"missing-required-option","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}