ValidationException: Missing the key ☁️ AWS

DynamoDB ValidationException: One or more parameter values were invalid: Missing the key pk in the item / The provided key element does not match the schema

The item or key doesn’t match the table’s primary key schema — wrong attribute name, wrong type, or missing sort key.

Seen on: AWS

Meaning

Every item needs the partition key (and sort key if defined) with the exact name and type (S, N, B). Using “id” when the table key is “pk”, sending a number as a string, or omitting the sort key in GetItem triggers it.

Common causes

  • Attribute name differs from the key schema
  • Wrong type (string vs number)
  • Sort key missing in GetItem/UpdateItem/DeleteItem
  • Empty string for a key attribute

⚡ Quick fix

  1. describe-table to see KeySchema and AttributeDefinitions
  2. Send both keys with matching names/types
  3. Use Query for partial-key lookups

Detailed fix by platform

AWS CLI

  1. aws dynamodb describe-table --table-name orders --query 'Table.[KeySchema,AttributeDefinitions]'

How to diagnose

  1. Schema — KeySchema names/types
  2. Request — Key object sent

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.