{"record":{"id":"97c3a46bb999fb17","repo":"risingwavelabs/risingwave","slug":"no-value-find-in-sink-schema-index-is","errorCode":null,"errorMessage":"no value find in sink schema, index is {:?}","messagePattern":"no value find in sink schema, index is (.+?)","errorType":"validation","errorClass":"SinkError","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/elasticsearch_opensearch/elasticsearch_opensearch_formatter.rs","lineNumber":69,"sourceCode":"    ) -> Result<Self> {\n        let key_format = if pk_indices.is_empty() {\n            let name = &schema\n                .fields()\n                .get(0)\n                .ok_or_else(|| {\n                    SinkError::ElasticSearchOpenSearch(anyhow!(\n                        \"no value find in sink schema, index is 0\"\n                    ))\n                })?\n                .name;\n            format!(\"{{{}}}\", name)\n        } else if pk_indices.len() == 1 {\n            let index = *pk_indices.get(0).unwrap();\n            let name = &schema\n                .fields()\n                .get(index)\n                .ok_or_else(|| {\n                    SinkError::ElasticSearchOpenSearch(anyhow!(\n                        \"no value find in sink schema, index is {:?}\",\n                        index\n                    ))\n                })?\n                .name;\n            format!(\"{{{}}}\", name)\n        } else {\n            let delimiter = delimiter\n                .as_ref()\n                .ok_or_else(|| anyhow!(\"please set the separator in the with option, when there are multiple primary key values\"))?\n                .clone();\n            let mut names = Vec::with_capacity(pk_indices.len());\n            for index in &pk_indices {\n                names.push(format!(\n                    \"{{{}}}\",\n                    schema\n                        .fields()\n                        .get(*index)","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/elasticsearch_opensearch/elasticsearch_opensearch_formatter.rs#L51-L87","documentation":"When the sink has exactly one primary key column, the formatter takes the field at that pk index to build the document key. If `schema.fields().get(index)` is None — the pk index points past the end of the schema — construction fails with 'no value find in sink schema, index is {index}'.","triggerScenarios":"Creating an Elasticsearch/OpenSearch sink with `pk_indices.len() == 1` whose stored index is out of bounds for the sink schema, i.e. a stale or inconsistent pk index computed against a different schema version.","commonSituations":"Schema changed (column dropped) after pk indices were computed; connector bug passing a pk index from the wrong schema; manual sink construction in tests with mismatched schema and pk_indices.","solutions":["Recreate the sink so pk_indices is recomputed against the current schema","Verify the primary key column still exists in the sink schema","Ensure the schema and pk_indices passed to the formatter come from the same schema version","If reproducible with a valid definition, file a RisingWave bug"],"exampleFix":"// before\n// pk index 3 but schema has 3 fields (0..2)\nElasticSearchOpenSearchFormatter::new(schema_of_3_fields, vec![3], ...)\n// after\nElasticSearchOpenSearchFormatter::new(schema_of_3_fields, vec![0], ...)","handlingStrategy":"validation","validationCode":"fn check_pk_in_bounds(schema: &Schema, pk_indices: &[usize]) -> Result<(), String> {\n    let n = schema.fields().len();\n    pk_indices.iter()\n        .find(|i| **i >= n)\n        .map_or(Ok(()), |i| Err(format!(\"pk index {} out of bounds (schema has {} fields)\", i, n)))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure pk_indices and the schema come from the same schema version","Recreate sinks after schema changes instead of reusing cached indices","Check the primary key column exists in the sink schema"],"tags":["rust","sink","formatter","schema","primary-key"],"backgroundTag":"index-out-of-range","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"}