The OTSInvalidPK: Validate PK size fail error occurs when the number of primary key columns in your SDK call does not match the number defined in the table. Fix your code to resolve this error. Retrying without code changes will not help.
Problem description
The following error is returned when using a Tablestore SDK to write or update data:
Caused by: [ErrorCode]:OTSInvalidPK, [Message]:Validate PK size fail
Cause
The number of primary key columns specified in your SDK call does not match the number defined when the table was created. For example, if the table has two primary key columns but your SDK call specifies only one, this error is returned.
Solution
Check the primary key definition of the table. In the Tablestore console, go to the table details page and view the Primary Key section. Alternatively, call the
DescribeTableAPI to retrieve the exact number and order of primary key columns.Update your SDK call so that the primary key columns exactly match the table definition — same number, same names, and same order.
Run the operation again to confirm the error is resolved.