Skip to content

Attempting to serialize bytes type causes error #5660

@ava-harris

Description

@ava-harris

PySDK Version

  • PySDK V2 (2.x)
  • PySDK V3 (3.x)

Describe the bug
When attempting to call the invoke function with a bytes object in the body, it throws an error during serialization. This is because bytes are not treated as a primitive.

elif is_not_primitive(value):
# if the value is a dict, use _serialize_shape() to serialize it recursively
return _serialize_shape(value)
else:
return value

def is_not_primitive(obj):
return not isinstance(obj, (int, float, str, bool, datetime.datetime))

To reproduce

from sagemaker.core.utils.utils import serialize
serialize({"body": b'1'})

Expected behavior

{'body': b'1'}

Screenshots or logs
If applicable, add screenshots or logs to help explain your problem.

Image Image Image

System information
A description of your system. Please provide:

  • SageMaker Python SDK version: 3.6.0
  • Framework name (eg. PyTorch) or algorithm (eg. KMeans): N/A
  • Framework version: N/A
  • Python version: 3.12.9
  • CPU or GPU: N/A
  • Custom Docker image (Y/N): N

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions