prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  500 when creating a new account with a POST and forgetting to put the ID
  ```
    File "kinto/plugins/accounts/views.py", line 112, in process_record
      if new[self.model.id_field] != self.request.selected_userid:
  KeyError: 'id'
  ```
  
  --- 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/plugins/accounts/__init__.py`
  Content:
  ```
  1 from kinto.authorization import PERMISSIONS_INHERITANCE_TREE
  2 from pyramid.exceptions import ConfigurationError
  3 
  4 
  5 def includeme(config):
  6     config.add_api_capability(
  7         'accounts',
  8         description='Manage user accounts.',
  9         url='https://kinto.readthedocs.io/en/latest/api/1.x/accounts.html')
  10 
  11     config.scan('kinto.plugins.accounts.views')
  12 
  13     PERMISSIONS_INHERITANCE_TREE[''].update({
  14         'account:create': {}
  15     })
  16     PERMISSIONS_INHERITANCE_TREE['account'] = {
  17         'write': {'account': ['write']},
  18         'read': {'account': ['write', 'read']}
  19     }
  20 
  21     # Add some safety to avoid weird behaviour with basicauth default policy.
  22     settings = config.get_settings()
  23     auth_policies = settings['multiauth.policies']
  24     if 'basicauth' in auth_policies and 'account' in auth_policies:
  25         if auth_policies.index('basicauth') < auth_policies.index('account'):
  26             error_msg = ("'basicauth' should not be mentioned before 'account' "
  27                          "in 'multiauth.policies' setting.")
  28             raise ConfigurationError(error_msg)
  29
  ```
  
  Path: `kinto/plugins/accounts/views.py`
  Content:
  ```
  1 import bcrypt
  2 import colander
  3 from pyramid import httpexceptions
  4 from pyramid.decorator import reify
  5 from pyramid.security import Authenticated, Everyone
  6 from pyramid.settings import aslist
  7 
  8 from kinto.views import NameGenerator
  9 from kinto.core import resource
  10 from kinto.core.errors import raise_invalid, http_error
  11 
  12 
  13 def _extract_posted_body_id(request):
  14     try:
  15         # Anonymous creation with POST.
  16         return request.json['data']['id']
  17     except (ValueError, KeyError):
  18         # Bad POST data.
  19         if request.method.lower() == 'post':
  20             error_details = {
  21                 'name': 'data.id',
  22                 'description': 'data.id in body: Required'
  23             }
  24             raise_invalid(request, **error_details)
  25         # Anonymous GET
  26         error_msg = 'Cannot read accounts.'
  27         raise http_error(httpexceptions.HTTPUnauthorized(), error=error_msg)
  28 
  29 
  30 class AccountSchema(resource.ResourceSchema):
  31     password = colander.SchemaNode(colander.String())
  32 
  33 
  34 @resource.register()
  35 class Account(resource.ShareableResource):
  36 
  37     schema = AccountSchema
  38 
  39     def __init__(self, request, context):
  40         # Store if current user is administrator (before accessing get_parent_id())
  41         allowed_from_settings = request.registry.settings.get('account_write_principals', [])
  42         context.is_administrator = len(set(aslist(allowed_from_settings)) &
  43                                        set(request.prefixed_principals)) > 0
  44         # Shortcut to check if current is anonymous (before get_parent_id()).
  45         context.is_anonymous = Authenticated not in request.effective_principals
  46 
  47         super().__init__(request, context)
  48 
  49         # Overwrite the current principal set by ShareableResource.
  50         if self.model.current_principal == Everyone or context.is_administrator:
  51             # Creation is anonymous, but author with write perm is this:
  52             # XXX: only works if policy name is account in settings.
  53             self.model.current_principal = 'account:{}'.format(self.model.parent_id)
  54 
  55     @reify
  56     def id_generator(self):
  57         # This generator is used for ID validation.
  58         return NameGenerator()
  59 
  60     def get_parent_id(self, request):
  61         # The whole challenge here is that we want to isolate what
  62         # authenticated users can list, but give access to everything to
  63         # administrators.
  64         # Plus when anonymous create accounts, we have to set their parent id
  65         # to the same value they would obtain when authenticated.
  66         if self.context.is_administrator:
  67             if self.context.on_collection:
  68                 # Accounts created by admin should have userid as parent.
  69                 if request.method.lower() == 'post':
  70                     return _extract_posted_body_id(request)
  71                 else:
  72                     # Admin see all accounts.
  73                     return '*'
  74             else:
  75                 # No pattern matching for admin on single record.
  76                 return request.matchdict['id']
  77 
  78         if not self.context.is_anonymous:
  79             # Authenticated users see their own account only.
  80             return request.selected_userid
  81 
  82         # Anonymous creation with PUT.
  83         if 'id' in request.matchdict:
  84             return request.matchdict['id']
  85 
  86         return _extract_posted_body_id(request)
  87 
  88     def collection_post(self):
  89         result = super(Account, self).collection_post()
  90         if self.context.is_anonymous and self.request.response.status_code == 200:
  91             error_details = {
  92                 'message': 'Account ID %r already exists' % result['data']['id']
  93             }
  94             raise http_error(httpexceptions.HTTPForbidden(), **error_details)
  95         return result
  96 
  97     def process_record(self, new, old=None):
  98         new = super(Account, self).process_record(new, old)
  99 
  100         # Store password safely in database as str
  101         # (bcrypt.hashpw returns base64 bytes).
  102         pwd_str = new["password"].encode(encoding='utf-8')
  103         hashed = bcrypt.hashpw(pwd_str, bcrypt.gensalt())
  104         new["password"] = hashed.decode(encoding='utf-8')
  105 
  106         # Administrators can reach other accounts and anonymous have no
  107         # selected_userid. So do not try to enforce.
  108         if self.context.is_administrator or self.context.is_anonymous:
  109             return new
  110 
  111         # Otherwise, we force the id to match the authenticated username.
  112         if new[self.model.id_field] != self.request.selected_userid:
  113             error_details = {
  114                 'name': 'data.id',
  115                 'description': 'Username and account ID do not match.',
  116             }
  117             raise_invalid(self.request, **error_details)
  118 
  119         return new
  120
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/kinto/plugins/accounts/__init__.py b/kinto/plugins/accounts/__init__.py
  --- a/kinto/plugins/accounts/__init__.py
  +++ b/kinto/plugins/accounts/__init__.py
  @@ -26,3 +26,24 @@
               error_msg = ("'basicauth' should not be mentioned before 'account' "
                            "in 'multiauth.policies' setting.")
               raise ConfigurationError(error_msg)
  +
  +    # We assume anyone in account_create_principals is to create
  +    # accounts for other people.
  +    # No one can create accounts for other people unless they are an
  +    # "admin", defined as someone matching account_write_principals.
  +    # Therefore any account that is in account_create_principals
  +    # should be in account_write_principals too.
  +    creators = set(settings.get('account_create_principals', '').split())
  +    admins = set(settings.get('account_write_principals', '').split())
  +    cant_create_anything = creators.difference(admins)
  +    # system.Everyone isn't an account.
  +    cant_create_anything.discard('system.Everyone')
  +    if cant_create_anything:
  +        message = ('Configuration has some principals in account_create_principals '
  +                   'but not in account_write_principals. These principals will only be '
  +                   'able to create their own accounts. This may not be what you want.\n'
  +                   'If you want these users to be able to create accounts for other users, '
  +                   'add them to account_write_principals.\n'
  +                   'Affected users: {}'.format(list(cant_create_anything)))
  +
  +        raise ConfigurationError(message)
  diff --git a/kinto/plugins/accounts/views.py b/kinto/plugins/accounts/views.py
  --- a/kinto/plugins/accounts/views.py
  +++ b/kinto/plugins/accounts/views.py
  @@ -27,6 +27,12 @@
           raise http_error(httpexceptions.HTTPUnauthorized(), error=error_msg)
   
   
  +class AccountIdGenerator(NameGenerator):
  +    """Allow @ signs in account IDs."""
  +
  +    regexp = r'^[a-zA-Z0-9][.@a-zA-Z0-9_-]*$'
  +
  +
   class AccountSchema(resource.ResourceSchema):
       password = colander.SchemaNode(colander.String())
   
  @@ -55,7 +61,7 @@
       @reify
       def id_generator(self):
           # This generator is used for ID validation.
  -        return NameGenerator()
  +        return AccountIdGenerator()
   
       def get_parent_id(self, request):
           # The whole challenge here is that we want to isolate what
  @@ -108,6 +114,14 @@
           if self.context.is_administrator or self.context.is_anonymous:
               return new
   
  +        # Do not let accounts be created without usernames.
  +        if self.model.id_field not in new:
  +            error_details = {
  +                'name': 'data.id',
  +                'description': 'Accounts must have an ID.',
  +            }
  +            raise_invalid(self.request, **error_details)
  +
           # Otherwise, we force the id to match the authenticated username.
           if new[self.model.id_field] != self.request.selected_userid:
               error_details = {
  
verification_info: {"golden_diff": "diff --git a/kinto/plugins/accounts/__init__.py b/kinto/plugins/accounts/__init__.py\n--- a/kinto/plugins/accounts/__init__.py\n+++ b/kinto/plugins/accounts/__init__.py\n@@ -26,3 +26,24 @@\n             error_msg = (\"'basicauth' should not be mentioned before 'account' \"\n                          \"in 'multiauth.policies' setting.\")\n             raise ConfigurationError(error_msg)\n+\n+    # We assume anyone in account_create_principals is to create\n+    # accounts for other people.\n+    # No one can create accounts for other people unless they are an\n+    # \"admin\", defined as someone matching account_write_principals.\n+    # Therefore any account that is in account_create_principals\n+    # should be in account_write_principals too.\n+    creators = set(settings.get('account_create_principals', '').split())\n+    admins = set(settings.get('account_write_principals', '').split())\n+    cant_create_anything = creators.difference(admins)\n+    # system.Everyone isn't an account.\n+    cant_create_anything.discard('system.Everyone')\n+    if cant_create_anything:\n+        message = ('Configuration has some principals in account_create_principals '\n+                   'but not in account_write_principals. These principals will only be '\n+                   'able to create their own accounts. This may not be what you want.\\n'\n+                   'If you want these users to be able to create accounts for other users, '\n+                   'add them to account_write_principals.\\n'\n+                   'Affected users: {}'.format(list(cant_create_anything)))\n+\n+        raise ConfigurationError(message)\ndiff --git a/kinto/plugins/accounts/views.py b/kinto/plugins/accounts/views.py\n--- a/kinto/plugins/accounts/views.py\n+++ b/kinto/plugins/accounts/views.py\n@@ -27,6 +27,12 @@\n         raise http_error(httpexceptions.HTTPUnauthorized(), error=error_msg)\n \n \n+class AccountIdGenerator(NameGenerator):\n+    \"\"\"Allow @ signs in account IDs.\"\"\"\n+\n+    regexp = r'^[a-zA-Z0-9][.@a-zA-Z0-9_-]*$'\n+\n+\n class AccountSchema(resource.ResourceSchema):\n     password = colander.SchemaNode(colander.String())\n \n@@ -55,7 +61,7 @@\n     @reify\n     def id_generator(self):\n         # This generator is used for ID validation.\n-        return NameGenerator()\n+        return AccountIdGenerator()\n \n     def get_parent_id(self, request):\n         # The whole challenge here is that we want to isolate what\n@@ -108,6 +114,14 @@\n         if self.context.is_administrator or self.context.is_anonymous:\n             return new\n \n+        # Do not let accounts be created without usernames.\n+        if self.model.id_field not in new:\n+            error_details = {\n+                'name': 'data.id',\n+                'description': 'Accounts must have an ID.',\n+            }\n+            raise_invalid(self.request, **error_details)\n+\n         # Otherwise, we force the id to match the authenticated username.\n         if new[self.model.id_field] != self.request.selected_userid:\n             error_details = {\n", "issue": "500 when creating a new account with a POST and forgetting to put the ID\n```\r\n  File \"kinto/plugins/accounts/views.py\", line 112, in process_record\r\n    if new[self.model.id_field] != self.request.selected_userid:\r\nKeyError: 'id'\r\n```\n", "before_files": [{"content": "from kinto.authorization import PERMISSIONS_INHERITANCE_TREE\nfrom pyramid.exceptions import ConfigurationError\n\n\ndef includeme(config):\n    config.add_api_capability(\n        'accounts',\n        description='Manage user accounts.',\n        url='https://kinto.readthedocs.io/en/latest/api/1.x/accounts.html')\n\n    config.scan('kinto.plugins.accounts.views')\n\n    PERMISSIONS_INHERITANCE_TREE[''].update({\n        'account:create': {}\n    })\n    PERMISSIONS_INHERITANCE_TREE['account'] = {\n        'write': {'account': ['write']},\n        'read': {'account': ['write', 'read']}\n    }\n\n    # Add some safety to avoid weird behaviour with basicauth default policy.\n    settings = config.get_settings()\n    auth_policies = settings['multiauth.policies']\n    if 'basicauth' in auth_policies and 'account' in auth_policies:\n        if auth_policies.index('basicauth') < auth_policies.index('account'):\n            error_msg = (\"'basicauth' should not be mentioned before 'account' \"\n                         \"in 'multiauth.policies' setting.\")\n            raise ConfigurationError(error_msg)\n", "path": "kinto/plugins/accounts/__init__.py"}, {"content": "import bcrypt\nimport colander\nfrom pyramid import httpexceptions\nfrom pyramid.decorator import reify\nfrom pyramid.security import Authenticated, Everyone\nfrom pyramid.settings import aslist\n\nfrom kinto.views import NameGenerator\nfrom kinto.core import resource\nfrom kinto.core.errors import raise_invalid, http_error\n\n\ndef _extract_posted_body_id(request):\n    try:\n        # Anonymous creation with POST.\n        return request.json['data']['id']\n    except (ValueError, KeyError):\n        # Bad POST data.\n        if request.method.lower() == 'post':\n            error_details = {\n                'name': 'data.id',\n                'description': 'data.id in body: Required'\n            }\n            raise_invalid(request, **error_details)\n        # Anonymous GET\n        error_msg = 'Cannot read accounts.'\n        raise http_error(httpexceptions.HTTPUnauthorized(), error=error_msg)\n\n\nclass AccountSchema(resource.ResourceSchema):\n    password = colander.SchemaNode(colander.String())\n\n\n@resource.register()\nclass Account(resource.ShareableResource):\n\n    schema = AccountSchema\n\n    def __init__(self, request, context):\n        # Store if current user is administrator (before accessing get_parent_id())\n        allowed_from_settings = request.registry.settings.get('account_write_principals', [])\n        context.is_administrator = len(set(aslist(allowed_from_settings)) &\n                                       set(request.prefixed_principals)) > 0\n        # Shortcut to check if current is anonymous (before get_parent_id()).\n        context.is_anonymous = Authenticated not in request.effective_principals\n\n        super().__init__(request, context)\n\n        # Overwrite the current principal set by ShareableResource.\n        if self.model.current_principal == Everyone or context.is_administrator:\n            # Creation is anonymous, but author with write perm is this:\n            # XXX: only works if policy name is account in settings.\n            self.model.current_principal = 'account:{}'.format(self.model.parent_id)\n\n    @reify\n    def id_generator(self):\n        # This generator is used for ID validation.\n        return NameGenerator()\n\n    def get_parent_id(self, request):\n        # The whole challenge here is that we want to isolate what\n        # authenticated users can list, but give access to everything to\n        # administrators.\n        # Plus when anonymous create accounts, we have to set their parent id\n        # to the same value they would obtain when authenticated.\n        if self.context.is_administrator:\n            if self.context.on_collection:\n                # Accounts created by admin should have userid as parent.\n                if request.method.lower() == 'post':\n                    return _extract_posted_body_id(request)\n                else:\n                    # Admin see all accounts.\n                    return '*'\n            else:\n                # No pattern matching for admin on single record.\n                return request.matchdict['id']\n\n        if not self.context.is_anonymous:\n            # Authenticated users see their own account only.\n            return request.selected_userid\n\n        # Anonymous creation with PUT.\n        if 'id' in request.matchdict:\n            return request.matchdict['id']\n\n        return _extract_posted_body_id(request)\n\n    def collection_post(self):\n        result = super(Account, self).collection_post()\n        if self.context.is_anonymous and self.request.response.status_code == 200:\n            error_details = {\n                'message': 'Account ID %r already exists' % result['data']['id']\n            }\n            raise http_error(httpexceptions.HTTPForbidden(), **error_details)\n        return result\n\n    def process_record(self, new, old=None):\n        new = super(Account, self).process_record(new, old)\n\n        # Store password safely in database as str\n        # (bcrypt.hashpw returns base64 bytes).\n        pwd_str = new[\"password\"].encode(encoding='utf-8')\n        hashed = bcrypt.hashpw(pwd_str, bcrypt.gensalt())\n        new[\"password\"] = hashed.decode(encoding='utf-8')\n\n        # Administrators can reach other accounts and anonymous have no\n        # selected_userid. So do not try to enforce.\n        if self.context.is_administrator or self.context.is_anonymous:\n            return new\n\n        # Otherwise, we force the id to match the authenticated username.\n        if new[self.model.id_field] != self.request.selected_userid:\n            error_details = {\n                'name': 'data.id',\n                'description': 'Username and account ID do not match.',\n            }\n            raise_invalid(self.request, **error_details)\n\n        return new\n", "path": "kinto/plugins/accounts/views.py"}], "after_files": [{"content": "from kinto.authorization import PERMISSIONS_INHERITANCE_TREE\nfrom pyramid.exceptions import ConfigurationError\n\n\ndef includeme(config):\n    config.add_api_capability(\n        'accounts',\n        description='Manage user accounts.',\n        url='https://kinto.readthedocs.io/en/latest/api/1.x/accounts.html')\n\n    config.scan('kinto.plugins.accounts.views')\n\n    PERMISSIONS_INHERITANCE_TREE[''].update({\n        'account:create': {}\n    })\n    PERMISSIONS_INHERITANCE_TREE['account'] = {\n        'write': {'account': ['write']},\n        'read': {'account': ['write', 'read']}\n    }\n\n    # Add some safety to avoid weird behaviour with basicauth default policy.\n    settings = config.get_settings()\n    auth_policies = settings['multiauth.policies']\n    if 'basicauth' in auth_policies and 'account' in auth_policies:\n        if auth_policies.index('basicauth') < auth_policies.index('account'):\n            error_msg = (\"'basicauth' should not be mentioned before 'account' \"\n                         \"in 'multiauth.policies' setting.\")\n            raise ConfigurationError(error_msg)\n\n    # We assume anyone in account_create_principals is to create\n    # accounts for other people.\n    # No one can create accounts for other people unless they are an\n    # \"admin\", defined as someone matching account_write_principals.\n    # Therefore any account that is in account_create_principals\n    # should be in account_write_principals too.\n    creators = set(settings.get('account_create_principals', '').split())\n    admins = set(settings.get('account_write_principals', '').split())\n    cant_create_anything = creators.difference(admins)\n    # system.Everyone isn't an account.\n    cant_create_anything.discard('system.Everyone')\n    if cant_create_anything:\n        message = ('Configuration has some principals in account_create_principals '\n                   'but not in account_write_principals. These principals will only be '\n                   'able to create their own accounts. This may not be what you want.\\n'\n                   'If you want these users to be able to create accounts for other users, '\n                   'add them to account_write_principals.\\n'\n                   'Affected users: {}'.format(list(cant_create_anything)))\n\n        raise ConfigurationError(message)\n", "path": "kinto/plugins/accounts/__init__.py"}, {"content": "import bcrypt\nimport colander\nfrom pyramid import httpexceptions\nfrom pyramid.decorator import reify\nfrom pyramid.security import Authenticated, Everyone\nfrom pyramid.settings import aslist\n\nfrom kinto.views import NameGenerator\nfrom kinto.core import resource\nfrom kinto.core.errors import raise_invalid, http_error\n\n\ndef _extract_posted_body_id(request):\n    try:\n        # Anonymous creation with POST.\n        return request.json['data']['id']\n    except (ValueError, KeyError):\n        # Bad POST data.\n        if request.method.lower() == 'post':\n            error_details = {\n                'name': 'data.id',\n                'description': 'data.id in body: Required'\n            }\n            raise_invalid(request, **error_details)\n        # Anonymous GET\n        error_msg = 'Cannot read accounts.'\n        raise http_error(httpexceptions.HTTPUnauthorized(), error=error_msg)\n\n\nclass AccountIdGenerator(NameGenerator):\n    \"\"\"Allow @ signs in account IDs.\"\"\"\n\n    regexp = r'^[a-zA-Z0-9][.@a-zA-Z0-9_-]*$'\n\n\nclass AccountSchema(resource.ResourceSchema):\n    password = colander.SchemaNode(colander.String())\n\n\n@resource.register()\nclass Account(resource.ShareableResource):\n\n    schema = AccountSchema\n\n    def __init__(self, request, context):\n        # Store if current user is administrator (before accessing get_parent_id())\n        allowed_from_settings = request.registry.settings.get('account_write_principals', [])\n        context.is_administrator = len(set(aslist(allowed_from_settings)) &\n                                       set(request.prefixed_principals)) > 0\n        # Shortcut to check if current is anonymous (before get_parent_id()).\n        context.is_anonymous = Authenticated not in request.effective_principals\n\n        super().__init__(request, context)\n\n        # Overwrite the current principal set by ShareableResource.\n        if self.model.current_principal == Everyone or context.is_administrator:\n            # Creation is anonymous, but author with write perm is this:\n            # XXX: only works if policy name is account in settings.\n            self.model.current_principal = 'account:{}'.format(self.model.parent_id)\n\n    @reify\n    def id_generator(self):\n        # This generator is used for ID validation.\n        return AccountIdGenerator()\n\n    def get_parent_id(self, request):\n        # The whole challenge here is that we want to isolate what\n        # authenticated users can list, but give access to everything to\n        # administrators.\n        # Plus when anonymous create accounts, we have to set their parent id\n        # to the same value they would obtain when authenticated.\n        if self.context.is_administrator:\n            if self.context.on_collection:\n                # Accounts created by admin should have userid as parent.\n                if request.method.lower() == 'post':\n                    return _extract_posted_body_id(request)\n                else:\n                    # Admin see all accounts.\n                    return '*'\n            else:\n                # No pattern matching for admin on single record.\n                return request.matchdict['id']\n\n        if not self.context.is_anonymous:\n            # Authenticated users see their own account only.\n            return request.selected_userid\n\n        # Anonymous creation with PUT.\n        if 'id' in request.matchdict:\n            return request.matchdict['id']\n\n        return _extract_posted_body_id(request)\n\n    def collection_post(self):\n        result = super(Account, self).collection_post()\n        if self.context.is_anonymous and self.request.response.status_code == 200:\n            error_details = {\n                'message': 'Account ID %r already exists' % result['data']['id']\n            }\n            raise http_error(httpexceptions.HTTPForbidden(), **error_details)\n        return result\n\n    def process_record(self, new, old=None):\n        new = super(Account, self).process_record(new, old)\n\n        # Store password safely in database as str\n        # (bcrypt.hashpw returns base64 bytes).\n        pwd_str = new[\"password\"].encode(encoding='utf-8')\n        hashed = bcrypt.hashpw(pwd_str, bcrypt.gensalt())\n        new[\"password\"] = hashed.decode(encoding='utf-8')\n\n        # Administrators can reach other accounts and anonymous have no\n        # selected_userid. So do not try to enforce.\n        if self.context.is_administrator or self.context.is_anonymous:\n            return new\n\n        # Do not let accounts be created without usernames.\n        if self.model.id_field not in new:\n            error_details = {\n                'name': 'data.id',\n                'description': 'Accounts must have an ID.',\n            }\n            raise_invalid(self.request, **error_details)\n\n        # Otherwise, we force the id to match the authenticated username.\n        if new[self.model.id_field] != self.request.selected_userid:\n            error_details = {\n                'name': 'data.id',\n                'description': 'Username and account ID do not match.',\n            }\n            raise_invalid(self.request, **error_details)\n\n        return new\n", "path": "kinto/plugins/accounts/views.py"}]}