{"record":{"id":"a80403ae7caa91ed","repo":"risingwavelabs/risingwave","slug":"encode-text-is-only-valid-as-key-encode","errorCode":null,"errorMessage":"ENCODE TEXT is only valid as key encode.","messagePattern":"ENCODE TEXT is only valid as key encode\\.","errorType":"validation","errorClass":"SinkError","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/formatter/mod.rs","lineNumber":579,"sourceCode":"                (F::Upsert, E::Avro, Some(E::Text)) => Impl::UpsertTextAvro(build(p).await?),\n                (F::Upsert, E::Avro, Some(E::Bytes)) => {\n                    Impl::UpsertBytesAvro(build(p).await?)\n                }\n                (F::Upsert, E::Avro, None) => Impl::UpsertAvro(build(p).await?),\n                (F::Upsert, E::Protobuf, Some(E::Text)) => Impl::UpsertTextProto(build(p).await?),\n                (F::Upsert, E::Protobuf, Some(E::Bytes)) => {\n                    Impl::UpsertBytesProto(build(p).await?)\n                }\n                (F::Upsert, E::Template, Some(E::Text)) => {\n                    Impl::UpsertTextTemplate(build(p).await?)\n                }\n                (F::Upsert, E::Template, Some(E::Bytes)) => {\n                    Impl::UpsertBytesTemplate(build(p).await?)\n                }\n                (F::Upsert, E::Template, None) => Impl::UpsertTemplate(build(p).await?),\n                (F::Debezium, E::Json, None) => Impl::DebeziumJson(build(p).await?),\n                (F::AppendOnly | F::Upsert, E::Text, _) => {\n                    return Err(SinkError::Config(anyhow!(\n                        \"ENCODE TEXT is only valid as key encode.\"\n                    )));\n                }\n                (F::AppendOnly, E::Avro, _)\n                | (F::Upsert, E::Protobuf, _)\n                | (F::Upsert, E::Bytes, _)\n                | (F::Debezium, E::Json, Some(_))\n                | (F::Debezium, E::Avro | E::Protobuf | E::Template | E::Text | E::Bytes, _)\n                | (_, E::Parquet, _)\n                | (_, _, Some(E::Parquet))\n                | (F::AppendOnly, E::Bytes, Some(_))\n                | (F::AppendOnly | F::Upsert, _, Some(E::Template) | Some(E::Json) | Some(E::Avro) | Some(E::Protobuf)) // reject other encode as key encode\n                => {\n                    return Err(SinkError::Config(anyhow!(\n                        \"sink format/encode/key_encode unsupported: {:?} {:?} {:?}\",\n                        format_desc.format,\n                        format_desc.encode,\n                        format_desc.key_encode","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/formatter/mod.rs#L561-L597","documentation":"The generic sink formatter dispatcher only allows ENCODE TEXT to serve as the KEY encoding (for key-only scenarios). When TEXT is chosen as the value encode for an AppendOnly or Upsert sink, it rejects the combination with this configuration error, because value serialization as plain text is not supported.","triggerScenarios":"Running `CREATE SINK ... FORMAT ... ENCODE TEXT` (or with an explicit key_encode) for AppendOnly/Upsert formats where TEXT lands in the value encode slot rather than the key encode slot.","commonSituations":"Users copying a key-only sink example and applying `ENCODE TEXT` at the value position; confusion between `key_encode` and `encode` options in the sink definition.","solutions":["Move `ENCODE TEXT` to the key encode position (use `KEY ENCODE TEXT`) and pick a supported value encode such as JSON or Avro","Use `ENCODE JSON` (or another supported encode) for the value if a full payload encode is needed","Check the FORMAT...ENCODE...VALIDATE syntax in the RisingWave sink docs"],"exampleFix":"// before\nCREATE SINK s FROM mv WITH (connector='kafka', FORMAT APPEND ONLY ENCODE TEXT);\n// after\nCREATE SINK s FROM mv WITH (connector='kafka', FORMAT APPEND ONLY ENCODE JSON KEY ENCODE TEXT);","handlingStrategy":"validation","validationCode":"fn validate_format(format: &str, encode: &str, key_encode: Option<&str>) -> Result<(), String> {\n    if encode.eq_ignore_ascii_case(\"text\") {\n        return Err(\"ENCODE TEXT is only valid as key encode\".into());\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember TEXT encode is key-only; always pair it with a value encode like JSON","Test sink DDL on a dev cluster before applying to production","Keep a template of valid FORMAT...ENCODE...KEY ENCODE combinations"],"tags":["sink","encode","config"],"backgroundTag":"unsupported-enum-value","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}