{"record":{"id":"ac47720d58c4d649","repo":"risingwavelabs/risingwave","slug":"risingwave-primary-key-column-index-is-out-of-r","errorCode":null,"errorMessage":"RisingWave primary key column index {} is out of range","messagePattern":"RisingWave primary key column index (.+?) is out of range","errorType":"validation","errorClass":"SinkError::DynamoDb","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/dynamodb.rs","lineNumber":407,"sourceCode":"            return Err(SinkError::DynamoDb(anyhow!(\"map is not supported yet\")));\n        }\n        DataType::Vector(_) => {\n            return Err(SinkError::DynamoDb(anyhow!(\"vector is not supported yet\")));\n        }\n    };\n    Ok(attr)\n}\n\nfn rw_pk_names(schema: &Schema, pk_indices: &[usize]) -> Result<Vec<String>> {\n    pk_indices\n        .iter()\n        .map(|pk_idx| {\n            schema\n                .fields()\n                .get(*pk_idx)\n                .map(|field| field.name.clone())\n                .ok_or_else(|| {\n                    SinkError::DynamoDb(anyhow!(\n                        \"RisingWave primary key column index {} is out of range\",\n                        pk_idx\n                    ))\n                })\n        })\n        .collect()\n}\n\nfn dynamodb_key_schema_names(\n    table_name: &str,\n    key_schema: &[KeySchemaElement],\n) -> Result<Vec<String>> {\n    if key_schema.is_empty() {\n        return Err(SinkError::DynamoDb(anyhow!(\n            \"table {} key schema is empty\",\n            table_name\n        )));\n    }","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/dynamodb.rs#L389-L425","documentation":"rw_pk_names maps each primary-key column index to its field name using the sink schema. If a pk index is >= the number of schema fields, .get() returns None and this error is thrown. It indicates the pk_indices no longer line up with the schema supplied to the sink.","triggerScenarios":"Internal wiring mismatch: pk_indices referencing columns absent from the schema passed to validate (e.g. after schema change on the upstream relation while a sink exists).","commonSituations":"Upstream table/materialized view altered (columns dropped/reordered) after sink creation; connector-internal invariant violation during sink recovery with a stale schema.","solutions":["Recreate the sink against the current relation schema so pk_indices match the schema.","Verify the upstream relation's primary key still exists and note its new column positions.","Report as a bug if it reproduces with an unmodified relation, since it indicates an internal invariant violation.","Restore/roll back the upstream schema change that removed or reordered PK columns."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// sanity-check pk indices against schema length before use\npk_indices.iter().all(|&i| i < schema.fields().len())","typeGuard":null,"tryCatchPattern":"// treat as internal invariant violation; log schema + pk_indices and recreate the sink\nmatch sink.validate().await {\n  Err(e) if e.to_string().contains(\"out of range\") => recreate_sink_with_current_schema(),\n  Err(e) => return Err(e),\n  Ok(()) => {},\n}","preventionTips":["Recreate sinks after altering upstream relation schemas/PKs.","Report persistent occurrences as connector bugs.","Avoid dropping or reordering PK columns on relations with active DynamoDB sinks."],"tags":["dynamodb","sink","index-out-of-bounds","schema","internal"],"backgroundTag":"index-out-of-bounds","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"}