{"record":{"id":"227abf71645b85cb","repo":"risingwavelabs/risingwave","slug":"cannot-find-key-format-please-set-it-or-use-j-227abf","errorCode":null,"errorMessage":"Cannot find '{KEY_FORMAT}', please set it or use JSON (stream value type)","messagePattern":"Cannot find '(.+?)', please set it or use JSON \\(stream value type\\)","errorType":"validation","errorClass":"SinkError::Config","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/redis.rs","lineNumber":476,"sourceCode":"                            \"Please specific either `{STREAM}` or `{STREAM_COLUMN}`. They are mutually exclusive options.\"\n                        )));\n                    }\n\n                    if let Some(stream_column) = stream_column\n                        && let Some(stream_column_type) = all_map.get(stream_column)\n                        && (stream_column_type != &DataType::Varchar)\n                    {\n                        return Err(SinkError::Config(anyhow!(\n                            \"`{STREAM_COLUMN}` must be set to `varchar`\"\n                        )));\n                    }\n\n                    let value_format =\n                        self.format_desc.options.get(VALUE_FORMAT).ok_or_else(|| {\n                            SinkError::Config(anyhow!(\"Cannot find `{VALUE_FORMAT}`\"))\n                        })?;\n                    let key_format = self.format_desc.options.get(KEY_FORMAT).ok_or_else(|| {\n                        SinkError::Config(anyhow!(\n                            \"Cannot find '{KEY_FORMAT}', please set it or use JSON\"\n                        ))\n                    })?;\n                    TemplateStringEncoder::check_string_format(key_format, &pk_map)?;\n                    TemplateStringEncoder::check_string_format(value_format, &all_map)?;\n                }\n                _ => {\n                    return Err(SinkError::Config(anyhow!(\n                        \"`{REDIS_VALUE_TYPE}` must be set to `{REDIS_VALUE_TYPE_STRING}` or `{REDIS_VALUE_TYPE_GEO}` or `{REDIS_VALUE_TYPE_PUBSUB}` or `{REDIS_VALUE_TYPE_STREAM}`\"\n                    )));\n                }\n            }\n        }\n        self.config.common.build_conn_and_pipe().await?;\n        Ok(())\n    }\n}\n","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/redis.rs#L458-L494","documentation":"For `value type = 'stream'`, the Redis sink also requires a `key format` template used to build the stream entry key from primary key columns. `validate` looks it up after `value format` and errors if it is missing, telling the user to set it or use JSON.","triggerScenarios":"Create a Redis stream sink with `value format` set but no `key format` option; primary key columns then have no way to be encoded into the entry key.","commonSituations":"Users assume the fixed `stream` name serves as the key and skip `key format`; configs copied from pubsub/string examples that don't need `key format`; misspelled option keys.","solutions":["Add `key format = '<template over pk columns>'` to the sink options.","Ensure the template placeholders reference primary key columns validated against `pk_map`.","Check spelling of the `key format` option key."],"exampleFix":"// before\nWITH (connector='redis', value type='stream', stream='events', value format='{{v}}')\n// after\nWITH (connector='redis', value type='stream', stream='events', key format='{{id}}', value format='{{v}}')","handlingStrategy":"validation","validationCode":"if (opts['value type'] === 'stream' && !opts['key format']) throw new Error('stream sink requires key format over pk columns');","typeGuard":null,"tryCatchPattern":"try { await createSink(cfg); } catch (e) { if (/Cannot find 'key format'/.test(String(e))) { cfg['key format'] = pkTemplate(pkColumns); await createSink(cfg); } else throw e; }","preventionTips":["Derive key format templates from primary key columns automatically","Include key format in redis stream sink config templates","Validate placeholders against actual pk column names"],"tags":["redis","sink","missing-option"],"backgroundTag":"missing-required-config-field","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}