Repository: localstack/localstack

Issue:
describe-stream for dynamodb streams crashes
Steps to recreate:
1. create table
```
aws dynamodb create-table --table-name MusicCollection --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --endpoint http://localhost:4569
```
2. add stream
```
aws dynamodb update-table --table-name MusicCollection --stream-specification StreamEnabled=true,StreamViewType=NEW_IMAGE --endpoint http://localhost:4569  
```
3. describe stream using the stream arn from step 2.
```
aws dynamodbstreams describe-stream --stream-arn "arn:aws:dynamodb:eu-central-1:000000000000:table/MusicCollection/stream/2019-09-21T14:06:37.345" --endpoint http://localhost:4570
```
localstack logs:

```
Traceback (most recent call last):
  File "/home/balrog/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/balrog/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/balrog/localstack/.venv/lib/python2.7/site-packages/flask_cors/extension.py", line 161, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/balrog/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/balrog/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/balrog/localstack/.venv/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/balrog/localstack/localstack/services/dynamodbstreams/dynamodbstreams_api.py", line 88, in post_request
    shard['ShardId'] = shard_id(stream_name, shard['ShardId'])
  File "/home/balrog/localstack/localstack/services/dynamodbstreams/dynamodbstreams_api.py", line 146, in shard_id
    return '-'.join([kinesis_shard_id, random_id(stream_arn, kinesis_shard_id)])
  File "/home/balrog/localstack/localstack/services/dynamodbstreams/dynamodbstreams_api.py", line 142, in random_id
    return uuid.uuid5(namespace, kinesis_shard_id).hex
  File "/usr/lib/python2.7/uuid.py", line 609, in uuid5
    hash = sha1(namespace.bytes + name).digest()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 4: ordinal not in range(128)
```


Discussion:

Resolving patch:
diff --git a/localstack/services/dynamodbstreams/dynamodbstreams_api.py b/localstack/services/dynamodbstreams/dynamodbstreams_api.py
--- a/localstack/services/dynamodbstreams/dynamodbstreams_api.py
+++ b/localstack/services/dynamodbstreams/dynamodbstreams_api.py
@@ -139,7 +139,7 @@ def stream_name_from_stream_arn(stream_arn):
 
 def random_id(stream_arn, kinesis_shard_id):
     namespace = uuid.UUID(bytes=hashlib.sha1(to_bytes(stream_arn)).digest()[:16])
-    return uuid.uuid5(namespace, kinesis_shard_id).hex
+    return uuid.uuid5(namespace, to_bytes(kinesis_shard_id)).hex
 
 
 def shard_id(stream_arn, kinesis_shard_id):


Test patch: