We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Default bucket UUID doesn't have dashes
I've seen that default record ID's have got dashes whereas default bucket id doesn't.

Does it makes sense to try to be consistent here?

```
$ http GET http://localhost:8888/v1/buckets/e93a0bb5b7d16d4f9bfd81b6d737271c -v --auth 'mary:marypassword'
{
    "data": {
        "id": "e93a0bb5b7d16d4f9bfd81b6d737271c", 
        "last_modified": 1436191171386
    }, 
    [...]
}
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kinto/views/buckets.py`
Content:
```
1 from pyramid.httpexceptions import HTTPForbidden, HTTPPreconditionFailed
2 from pyramid.security import NO_PERMISSION_REQUIRED
3 from pyramid.view import view_config
4 
5 from cliquet import resource
6 from cliquet.utils import hmac_digest, build_request
7 
8 from kinto.views import NameGenerator
9 
10 
11 def create_bucket(request, bucket_id):
12     """Create a bucket if it doesn't exists."""
13     bucket_put = (request.method.lower() == 'put' and
14                   request.path.endswith('buckets/default'))
15 
16     if not bucket_put:
17         subrequest = build_request(request, {
18             'method': 'PUT',
19             'path': '/buckets/%s' % bucket_id,
20             'body': {"data": {}},
21             'headers': {'If-None-Match': '*'.encode('utf-8')}
22         })
23 
24         try:
25             request.invoke_subrequest(subrequest)
26         except HTTPPreconditionFailed:
27             # The bucket already exists
28             pass
29 
30 
31 def create_collection(request, bucket_id):
32     subpath = request.matchdict['subpath']
33     if subpath.startswith('/collections/'):
34         collection_id = subpath.split('/')[2]
35         collection_put = (request.method.lower() == 'put' and
36                           request.path.endswith(collection_id))
37         if not collection_put:
38             subrequest = build_request(request, {
39                 'method': 'PUT',
40                 'path': '/buckets/%s/collections/%s' % (
41                     bucket_id, collection_id),
42                 'body': {"data": {}},
43                 'headers': {'If-None-Match': '*'.encode('utf-8')}
44             })
45             try:
46                 request.invoke_subrequest(subrequest)
47             except HTTPPreconditionFailed:
48                 # The collection already exists
49                 pass
50 
51 
52 @view_config(route_name='default_bucket', permission=NO_PERMISSION_REQUIRED)
53 def default_bucket(request):
54     if getattr(request, 'prefixed_userid', None) is None:
55         raise HTTPForbidden  # Pass through the forbidden_view_config
56 
57     settings = request.registry.settings
58     hmac_secret = settings['cliquet.userid_hmac_secret']
59     # Build the user unguessable bucket_id UUID from its user_id
60     bucket_id = hmac_digest(hmac_secret, request.prefixed_userid)[:32]
61     path = request.path.replace('default', bucket_id)
62     querystring = request.url[(request.url.index(request.path) +
63                                len(request.path)):]
64 
65     # Make sure bucket exists
66     create_bucket(request, bucket_id)
67 
68     # Make sure the collection exists
69     create_collection(request, bucket_id)
70 
71     subrequest = build_request(request, {
72         'method': request.method,
73         'path': path + querystring,
74         'body': request.body
75     })
76 
77     return request.invoke_subrequest(subrequest)
78 
79 
80 @resource.register(name='bucket',
81                    collection_methods=('GET',),
82                    collection_path='/buckets',
83                    record_path='/buckets/{{id}}')
84 class Bucket(resource.ProtectedResource):
85     permissions = ('read', 'write', 'collection:create', 'group:create')
86 
87     def __init__(self, *args, **kwargs):
88         super(Bucket, self).__init__(*args, **kwargs)
89         self.collection.id_generator = NameGenerator()
90 
91     def get_parent_id(self, request):
92         # Buckets are not isolated by user, unlike Cliquet resources.
93         return ''
94 
95     def delete(self):
96         result = super(Bucket, self).delete()
97 
98         # Delete groups.
99         storage = self.collection.storage
100         parent_id = '/buckets/%s' % self.record_id
101         storage.delete_all(collection_id='group', parent_id=parent_id)
102 
103         # Delete collections.
104         deleted = storage.delete_all(collection_id='collection',
105                                      parent_id=parent_id)
106 
107         # Delete records.
108         id_field = self.collection.id_field
109         for collection in deleted:
110             parent_id = '/buckets/%s/collections/%s' % (self.record_id,
111                                                         collection[id_field])
112             storage.delete_all(collection_id='record', parent_id=parent_id)
113 
114         return result
115
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kinto/views/buckets.py b/kinto/views/buckets.py
--- a/kinto/views/buckets.py
+++ b/kinto/views/buckets.py
@@ -1,3 +1,6 @@
+from six import text_type
+from uuid import UUID
+
 from pyramid.httpexceptions import HTTPForbidden, HTTPPreconditionFailed
 from pyramid.security import NO_PERMISSION_REQUIRED
 from pyramid.view import view_config
@@ -57,7 +60,8 @@
     settings = request.registry.settings
     hmac_secret = settings['cliquet.userid_hmac_secret']
     # Build the user unguessable bucket_id UUID from its user_id
-    bucket_id = hmac_digest(hmac_secret, request.prefixed_userid)[:32]
+    digest = hmac_digest(hmac_secret, request.prefixed_userid)
+    bucket_id = text_type(UUID(digest[:32]))
     path = request.path.replace('default', bucket_id)
     querystring = request.url[(request.url.index(request.path) +
                                len(request.path)):]

{"golden_diff": "diff --git a/kinto/views/buckets.py b/kinto/views/buckets.py\n--- a/kinto/views/buckets.py\n+++ b/kinto/views/buckets.py\n@@ -1,3 +1,6 @@\n+from six import text_type\n+from uuid import UUID\n+\n from pyramid.httpexceptions import HTTPForbidden, HTTPPreconditionFailed\n from pyramid.security import NO_PERMISSION_REQUIRED\n from pyramid.view import view_config\n@@ -57,7 +60,8 @@\n     settings = request.registry.settings\n     hmac_secret = settings['cliquet.userid_hmac_secret']\n     # Build the user unguessable bucket_id UUID from its user_id\n-    bucket_id = hmac_digest(hmac_secret, request.prefixed_userid)[:32]\n+    digest = hmac_digest(hmac_secret, request.prefixed_userid)\n+    bucket_id = text_type(UUID(digest[:32]))\n     path = request.path.replace('default', bucket_id)\n     querystring = request.url[(request.url.index(request.path) +\n                                len(request.path)):]\n", "issue": "Default bucket UUID doesn't have dashes\nI've seen that default record ID's have got dashes whereas default bucket id doesn't.\n\nDoes it makes sense to try to be consistent here?\n\n```\n$ http GET http://localhost:8888/v1/buckets/e93a0bb5b7d16d4f9bfd81b6d737271c -v --auth 'mary:marypassword'\n{\n    \"data\": {\n        \"id\": \"e93a0bb5b7d16d4f9bfd81b6d737271c\", \n        \"last_modified\": 1436191171386\n    }, \n    [...]\n}\n```\n\n", "before_files": [{"content": "from pyramid.httpexceptions import HTTPForbidden, HTTPPreconditionFailed\nfrom pyramid.security import NO_PERMISSION_REQUIRED\nfrom pyramid.view import view_config\n\nfrom cliquet import resource\nfrom cliquet.utils import hmac_digest, build_request\n\nfrom kinto.views import NameGenerator\n\n\ndef create_bucket(request, bucket_id):\n    \"\"\"Create a bucket if it doesn't exists.\"\"\"\n    bucket_put = (request.method.lower() == 'put' and\n                  request.path.endswith('buckets/default'))\n\n    if not bucket_put:\n        subrequest = build_request(request, {\n            'method': 'PUT',\n            'path': '/buckets/%s' % bucket_id,\n            'body': {\"data\": {}},\n            'headers': {'If-None-Match': '*'.encode('utf-8')}\n        })\n\n        try:\n            request.invoke_subrequest(subrequest)\n        except HTTPPreconditionFailed:\n            # The bucket already exists\n            pass\n\n\ndef create_collection(request, bucket_id):\n    subpath = request.matchdict['subpath']\n    if subpath.startswith('/collections/'):\n        collection_id = subpath.split('/')[2]\n        collection_put = (request.method.lower() == 'put' and\n                          request.path.endswith(collection_id))\n        if not collection_put:\n            subrequest = build_request(request, {\n                'method': 'PUT',\n                'path': '/buckets/%s/collections/%s' % (\n                    bucket_id, collection_id),\n                'body': {\"data\": {}},\n                'headers': {'If-None-Match': '*'.encode('utf-8')}\n            })\n            try:\n                request.invoke_subrequest(subrequest)\n            except HTTPPreconditionFailed:\n                # The collection already exists\n                pass\n\n\n@view_config(route_name='default_bucket', permission=NO_PERMISSION_REQUIRED)\ndef default_bucket(request):\n    if getattr(request, 'prefixed_userid', None) is None:\n        raise HTTPForbidden  # Pass through the forbidden_view_config\n\n    settings = request.registry.settings\n    hmac_secret = settings['cliquet.userid_hmac_secret']\n    # Build the user unguessable bucket_id UUID from its user_id\n    bucket_id = hmac_digest(hmac_secret, request.prefixed_userid)[:32]\n    path = request.path.replace('default', bucket_id)\n    querystring = request.url[(request.url.index(request.path) +\n                               len(request.path)):]\n\n    # Make sure bucket exists\n    create_bucket(request, bucket_id)\n\n    # Make sure the collection exists\n    create_collection(request, bucket_id)\n\n    subrequest = build_request(request, {\n        'method': request.method,\n        'path': path + querystring,\n        'body': request.body\n    })\n\n    return request.invoke_subrequest(subrequest)\n\n\n@resource.register(name='bucket',\n                   collection_methods=('GET',),\n                   collection_path='/buckets',\n                   record_path='/buckets/{{id}}')\nclass Bucket(resource.ProtectedResource):\n    permissions = ('read', 'write', 'collection:create', 'group:create')\n\n    def __init__(self, *args, **kwargs):\n        super(Bucket, self).__init__(*args, **kwargs)\n        self.collection.id_generator = NameGenerator()\n\n    def get_parent_id(self, request):\n        # Buckets are not isolated by user, unlike Cliquet resources.\n        return ''\n\n    def delete(self):\n        result = super(Bucket, self).delete()\n\n        # Delete groups.\n        storage = self.collection.storage\n        parent_id = '/buckets/%s' % self.record_id\n        storage.delete_all(collection_id='group', parent_id=parent_id)\n\n        # Delete collections.\n        deleted = storage.delete_all(collection_id='collection',\n                                     parent_id=parent_id)\n\n        # Delete records.\n        id_field = self.collection.id_field\n        for collection in deleted:\n            parent_id = '/buckets/%s/collections/%s' % (self.record_id,\n                                                        collection[id_field])\n            storage.delete_all(collection_id='record', parent_id=parent_id)\n\n        return result\n", "path": "kinto/views/buckets.py"}], "after_files": [{"content": "from six import text_type\nfrom uuid import UUID\n\nfrom pyramid.httpexceptions import HTTPForbidden, HTTPPreconditionFailed\nfrom pyramid.security import NO_PERMISSION_REQUIRED\nfrom pyramid.view import view_config\n\nfrom cliquet import resource\nfrom cliquet.utils import hmac_digest, build_request\n\nfrom kinto.views import NameGenerator\n\n\ndef create_bucket(request, bucket_id):\n    \"\"\"Create a bucket if it doesn't exists.\"\"\"\n    bucket_put = (request.method.lower() == 'put' and\n                  request.path.endswith('buckets/default'))\n\n    if not bucket_put:\n        subrequest = build_request(request, {\n            'method': 'PUT',\n            'path': '/buckets/%s' % bucket_id,\n            'body': {\"data\": {}},\n            'headers': {'If-None-Match': '*'.encode('utf-8')}\n        })\n\n        try:\n            request.invoke_subrequest(subrequest)\n        except HTTPPreconditionFailed:\n            # The bucket already exists\n            pass\n\n\ndef create_collection(request, bucket_id):\n    subpath = request.matchdict['subpath']\n    if subpath.startswith('/collections/'):\n        collection_id = subpath.split('/')[2]\n        collection_put = (request.method.lower() == 'put' and\n                          request.path.endswith(collection_id))\n        if not collection_put:\n            subrequest = build_request(request, {\n                'method': 'PUT',\n                'path': '/buckets/%s/collections/%s' % (\n                    bucket_id, collection_id),\n                'body': {\"data\": {}},\n                'headers': {'If-None-Match': '*'.encode('utf-8')}\n            })\n            try:\n                request.invoke_subrequest(subrequest)\n            except HTTPPreconditionFailed:\n                # The collection already exists\n                pass\n\n\n@view_config(route_name='default_bucket', permission=NO_PERMISSION_REQUIRED)\ndef default_bucket(request):\n    if getattr(request, 'prefixed_userid', None) is None:\n        raise HTTPForbidden  # Pass through the forbidden_view_config\n\n    settings = request.registry.settings\n    hmac_secret = settings['cliquet.userid_hmac_secret']\n    # Build the user unguessable bucket_id UUID from its user_id\n    digest = hmac_digest(hmac_secret, request.prefixed_userid)\n    bucket_id = text_type(UUID(digest[:32]))\n    path = request.path.replace('default', bucket_id)\n    querystring = request.url[(request.url.index(request.path) +\n                               len(request.path)):]\n\n    # Make sure bucket exists\n    create_bucket(request, bucket_id)\n\n    # Make sure the collection exists\n    create_collection(request, bucket_id)\n\n    subrequest = build_request(request, {\n        'method': request.method,\n        'path': path + querystring,\n        'body': request.body\n    })\n\n    return request.invoke_subrequest(subrequest)\n\n\n@resource.register(name='bucket',\n                   collection_methods=('GET',),\n                   collection_path='/buckets',\n                   record_path='/buckets/{{id}}')\nclass Bucket(resource.ProtectedResource):\n    permissions = ('read', 'write', 'collection:create', 'group:create')\n\n    def __init__(self, *args, **kwargs):\n        super(Bucket, self).__init__(*args, **kwargs)\n        self.collection.id_generator = NameGenerator()\n\n    def get_parent_id(self, request):\n        # Buckets are not isolated by user, unlike Cliquet resources.\n        return ''\n\n    def delete(self):\n        result = super(Bucket, self).delete()\n\n        # Delete groups.\n        storage = self.collection.storage\n        parent_id = '/buckets/%s' % self.record_id\n        storage.delete_all(collection_id='group', parent_id=parent_id)\n\n        # Delete collections.\n        deleted = storage.delete_all(collection_id='collection',\n                                     parent_id=parent_id)\n\n        # Delete records.\n        id_field = self.collection.id_field\n        for collection in deleted:\n            parent_id = '/buckets/%s/collections/%s' % (self.record_id,\n                                                        collection[id_field])\n            storage.delete_all(collection_id='record', parent_id=parent_id)\n\n        return result\n", "path": "kinto/views/buckets.py"}]}