dynobase-icon
Dynobase

Error: a bytes-like object is required not binary dynamodb

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

“A bytes-like object is required, not Binary” means a Python function received boto3’s Binary wrapper instead of raw bytes. This commonly occurs after reading a Binary attribute through the DynamoDB resource interface. Unwrap it before passing it to another library.

import boto3
from boto3.dynamodb.types import Binary

table = boto3.resource("dynamodb", region_name="us-east-1").Table("Files")
item = table.get_item(Key={"id": "file-123"})["Item"]
value = item["payload"]
payload = bytes(value.value) if isinstance(value, Binary) else bytes(value)
# Decode only if the stored bytes are known to contain UTF-8 text.
text = payload.decode("utf-8")

For compressed data, pass payload to the decompressor; for a hash, pass it to the hashing function. Do not use str(value) to obtain bytes, and do not base64-decode a payload that boto3 has already decoded.

On writes, the low-level client accepts {"B": b"payload"}, while a Table resource accepts native bytes or a Binary wrapper. The same distinction applies to binary expression values. Keep those API formats separate.

See boto3 data handling and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.