{"record":{"id":"992d60b89d923292","repo":"risingwavelabs/risingwave","slug":"table-key-schema-is-empty","errorCode":null,"errorMessage":"table {} key schema is empty","messagePattern":"table (.+?) key schema is empty","errorType":"validation","errorClass":"SinkError::DynamoDb","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/dynamodb.rs","lineNumber":421,"sourceCode":"                .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    }\n\n    Ok(key_schema\n        .iter()\n        .map(|key_element| key_element.attribute_name().to_owned())\n        .collect())\n}\n\nfn validate_pk_matches_dynamodb_key_schema(\n    table_name: &str,\n    rw_pk_names: &[String],\n    dynamodb_keys: &[String],\n) -> Result<()> {\n    let rw_pk_set = rw_pk_names.iter().collect::<BTreeSet<_>>();\n    let dynamodb_key_set = dynamodb_keys.iter().collect::<BTreeSet<_>>();","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/dynamodb.rs#L403-L439","documentation":"dynamodb_key_schema_names converts the DescribeTable key schema into key column names. DynamoDB normally guarantees at least one key element (HASH), so an empty key_schema means the AWS response lacked key information and the connector cannot align the RisingWave primary key with the table's key.","triggerScenarios":"DescribeTable returns a table whose KeySchema is empty/absent — e.g. a malformed or partially provisioned table entry, or mocked/test endpoints returning incomplete responses.","commonSituations":"Testing against dynamodb-local or mocks returning incomplete DescribeTable output; corrupted/abnormally created tables; AWS SDK version responses lacking key_schema.","solutions":["Inspect the table with `aws dynamodb describe-table --table-name <name>` and confirm a valid KeySchema (HASH required).","Recreate the table with a proper key schema (HASH, optionally + RANGE).","Check the AWS SDK/endpoint used; a broken mock or proxy may strip key_schema.","If on dynamodb-local or a mock, fix the fixture to return a realistic DescribeTable response."],"exampleFix":"// before: table created without key schema (invalid)\n// after\naws dynamodb create-table --table-name events --key-schema AttributeName=pk,KeyType=HASH --attribute-definitions AttributeName=pk,AttributeType=S --provisioned-throughput ReadCapacityUnits=1,WriteCapacityUnits=1","handlingStrategy":"validation","validationCode":"aws dynamodb describe-table --table-name events --query 'Table.KeySchema'  # must contain at least one HASH key element","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always create DynamoDB tables with an explicit HASH (and optional RANGE) key.","Use realistic DescribeTable responses in dynamodb-local/mocks and tests.","Validate table key schema after provisioning in CI."],"tags":["dynamodb","sink","key-schema","validation","empty"],"backgroundTag":"empty-required-field","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"}