You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: TypeError occurs when generating a Kinesis event. TypeError: Object of type bytes is not JSON serializable
Steps to reproduce the issue:
Run sam local generate-event kinesis
Observed result:
Traceback (most recent call last):
File "/Users/redacted/Library/Python/3.7/bin/sam", line 11, in <module>
sys.exit(cli())
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/samcli/commands/local/generate_event/kinesis/cli.py", line 36, in cli
do_cli(ctx, region, partition, sequence, data) # pragma: no cover
File "/Users/redacted/Library/Python/3.7/lib/python/site-packages/samcli/commands/local/generate_event/kinesis/cli.py", line 47, in do_cli
event = json.dumps(event_dict, indent=4)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 238, in dumps
**kw).encode(obj)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 201, in encode
chunks = list(chunks)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 325, in _iterencode_list
yield from chunks
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 405, in _iterencode_dict
yield from chunks
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 438, in _iterencode
o = _default(o)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable
Expected result:
Default event json output.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Mac 10.13.6
Python 3.6, Python 3.7
Output of sam --version: SAM CLI, version 0.5.0
and SAM CLI, version 0.4.0
Optional Debug logs:
Add --debug flag to command you are running
Additional Details:
commands/local/generate_event/kinesis/cli.py:45 date_base64 = base64.urlsafe_b64encode(data.encode('utf8'))
This returns a b'' (byte) type which cannot be serialized by json.dump changing the line to date_base64 = base64.urlsafe_b64encode(data.encode('utf8')).decode('utf-8') fixes the issue.
The text was updated successfully, but these errors were encountered:
Description: TypeError occurs when generating a Kinesis event.
TypeError: Object of type bytes is not JSON serializable
Steps to reproduce the issue:
sam local generate-event kinesis
Observed result:
Expected result:
Default event json output.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Mac 10.13.6
Python 3.6, Python 3.7
Output of
sam --version
:SAM CLI, version 0.5.0
and
SAM CLI, version 0.4.0
Optional Debug logs:
Add --debug flag to command you are running
Additional Details:
commands/local/generate_event/kinesis/cli.py:45
date_base64 = base64.urlsafe_b64encode(data.encode('utf8'))
This returns a
b''
(byte) type which cannot be serialized byjson.dump
changing the line todate_base64 = base64.urlsafe_b64encode(data.encode('utf8')).decode('utf-8')
fixes the issue.The text was updated successfully, but these errors were encountered: