Size of hashkey has exceeded the maximum size limit of 2048 bytes

TL;DR — DynamoDB caps key lengths: a partition (hash) key value can be at most 2048 bytes, and a sort (range) key value at most 1024 bytes, measured as UTF-8 (or raw binary) bytes. A write whose key exceeds the limit is rejected. Shorten the key — hash long values, or move the bulky data into a non-key attribute.

What it means

ValidationException: One or more parameter values were invalid: Size of hashkey
has exceeded the maximum size limit of 2048 bytes

Key attributes are indexed and physically partitioned by DynamoDB, so their length is bounded far below the 400 KB item limit. The partition key tops out at 2048 bytes and the sort key at 1024 bytes. The byte count is the encoded size (UTF-8 for strings, raw bytes for binary) — multi-byte characters count for more than one. It's an HTTP 400 ValidationException, client-side, not retryable until the key shrinks.

Why it happens

  • A long string as the partition key — a URL, full document, encoded blob, or concatenated composite key used directly as the key value.
  • A verbose composite sort key — many segments joined with # that together exceed 1024 bytes.
  • Base64 / serialized data in a key — encoding inflates the byte count past the limit.
  • Multi-byte text — non-ASCII content whose UTF-8 encoding is larger than the character count suggests.

How to fix it

  1. Hash the long value — store a deterministic digest (e.g. SHA-256, ~32 bytes) as the key and keep the full value in a separate non-key attribute.
  2. Choose a more compact key — a shorter natural identifier instead of the bulky field.
  3. Shorten the composite key — trim or abbreviate the segments that make up a #-joined sort key.
  4. Move oversized content out of the key into a regular attribute (which only has to fit the 400 KB item limit).

Bekerja dengan DynamoDB tanpa Console

DynoTable adalah klien desktop yang cepat untuk DynamoDB — jelajahi tabel, jalankan query gaya SQL, dan edit Item secara lokal.