boto / botocore

The low-level, core functionality of boto3 and the AWS CLI.
Apache License 2.0
1.49k stars 1.09k forks source link

Unable to write serialized protobuf to kinesis #1166

Closed weilu closed 7 years ago

weilu commented 7 years ago

I'm using boto3 (version 1.4.4) to talk to Kinesis:

import boto3
kinesis = boto3.client('kinesis')

# write a record with data '\x08' to the test stream
response = kinesis.put_record(StreamName='test', Data=b'\x08', PartitionKey='foobar')
print(response['ResponseMetadata']['HTTPStatusCode']) # 200

# now read from the test stream
shard_it = kinesis.get_shard_iterator(StreamName="test", ShardId='shardId-000000000000', ShardIteratorType="LATEST")["ShardIterator"]
response = kinesis.get_records(ShardIterator=shard_it, Limit=10)
print(response['ResponseMetadata']['HTTPStatusCode']) # 200
print(response['Records']) # [] # Where did my record go?

When I test it with any data without the \x escape I'm able to get back the record as expected. boto3's doc says that "The data blob can be any type of data; for example, a segment from a log file, geographic/location data, website clickstream data, and so on." then why is the message with \x escaped characters dropped? Am I expected to '\x08'.encode('string_escape') before sending the data to kinesis?

I have characters like \x08 in the message data because I'm trying to write a serialized protocol buffer message to a Kinesis stream.

weilu commented 7 years ago

Okay, this is due to my outdated version of botocore==1.4.62. Upgrading to 1.5.26 fixed it. Apparently that version of botocore is horribly broken in many ways. Can the bad version be unpublished or marked bad on pypi?

dstufft commented 7 years ago

I'm glad that you were able to get this to work! We don't remove releases from PyPI because that would break people who are currently using that version successfully despite its flaws.