We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
After upgrading to 8.21, Sentry upgrade wizard hangs on auth.allow-registration
When upgrading my onpremise installation form 8.20 to 8.21 (using docker-compose), the wizard prompted me to set the “Anonymize Beacon” option. When clicking “Continue”, the following error message pops up:
> An invalid value for (auth.allow-registration) was passed to the server.

There was no such option `auth.allow-registration` set in either `sentry.conf.py` or `config.yml`.

The call to `https://sentry.example.com/api/0/internal/options/` returned a 400, with the following params:
```
system.admin-email: admin@example.com
system.url-prefix | https://sentry.example.com
auth.allow-registration | 0
beacon.anonymous | true
```
I worked around that by resending the request, changing 0 for False. My install is now fine

Running `sentry config get auth.allow-registration`, whether before the fix or after, returns:
```
        type: BOOLEAN
 from config: <not set>
     current: 0
```
This looks somehow similar to #5699.

Hope that helps!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/sentry/utils/types.py`
Content:
```
1 """
2 sentry.utils.types
3 ~~~~~~~~~~~~~~~~~~
4 
5 :copyright: (c) 2010-2016 by the Sentry Team, see AUTHORS for more details.
6 :license: BSD, see LICENSE for more details.
7 """
8 from __future__ import absolute_import, print_function
9 
10 import six
11 
12 from yaml.parser import ParserError
13 from yaml.scanner import ScannerError
14 
15 from sentry.utils.yaml import safe_load
16 
17 __all__ = ('InvalidTypeError', 'Any', 'Bool', 'Int', 'Float', 'String', 'Dict', 'Sequence', )
18 
19 
20 class InvalidTypeError(TypeError):
21     pass
22 
23 
24 class Type(object):
25     """Base Type that provides type coersion"""
26     name = ''
27     # Default value to be returned when initializing
28     default = None
29     # Types that do not need to be coerced
30     expected_types = ()
31     # Types that are acceptable for coersion
32     compatible_types = six.string_types
33 
34     def __call__(self, value=None):
35         if value is None:
36             return self._default()
37         if self.test(value):
38             return value
39         if isinstance(value, self.compatible_types):
40             rv = self.convert(value)
41             # Make sure convert was able to do the right thing
42             # and give us the type we were expecting
43             if self.test(rv):
44                 return rv
45         raise InvalidTypeError('{!r} is not a valid {}'.format(value, repr(self)))
46 
47     def convert(self, value):
48         return value
49 
50     def _default(self):
51         return self.default
52 
53     def test(self, value):
54         """Check if the value is the correct type or not"""
55         return isinstance(value, self.expected_types)
56 
57     def __repr__(self):
58         return self.name
59 
60 
61 class AnyType(Type):
62     """A type that accepts any value and does no coersion"""
63     name = 'any'
64     expected_types = (object, )
65     compatible_types = (object, )
66 
67 
68 class BoolType(Type):
69     "Coerce a boolean from a string"
70     name = 'boolean'
71     default = False
72     expected_types = (bool, )
73 
74     def convert(self, value):
75         value = value.lower()
76         if value in ('y', 'yes', 't', 'true', '1', 'on'):
77             return True
78         if value in ('n', 'no', 'f', 'false', '0', 'off'):
79             return False
80 
81 
82 class IntType(Type):
83     """Coerce an integer from a string"""
84     name = 'integer'
85     default = 0
86     expected_types = six.integer_types
87 
88     def convert(self, value):
89         try:
90             return int(value)
91         except ValueError:
92             return
93 
94 
95 class FloatType(Type):
96     """Coerce a float from a string or integer"""
97     name = 'float'
98     default = 0.0
99     expected_types = (float, )
100     compatible_types = six.string_types + six.integer_types + (float, )
101 
102     def convert(self, value):
103         try:
104             return float(value)
105         except ValueError:
106             return
107 
108 
109 class StringType(Type):
110     """String type without any coersion, must be a string"""
111     name = 'string'
112     default = u''
113     expected_types = six.string_types
114     compatible_types = six.string_types
115 
116 
117 class DictType(Type):
118     """Coerce a dict out of a json/yaml string"""
119     name = 'dictionary'
120     expected_types = (dict, )
121 
122     def _default(self):
123         # make sure we create a fresh dict each time
124         return {}
125 
126     def convert(self, value):
127         try:
128             return safe_load(value)
129         except (AttributeError, ParserError, ScannerError):
130             return
131 
132 
133 class SequenceType(Type):
134     """Coerce a tuple out of a json/yaml string or a list"""
135     name = 'sequence'
136     default = ()
137     expected_types = (tuple, list)
138     compatible_types = six.string_types + (tuple, list)
139 
140     def convert(self, value):
141         if isinstance(value, six.string_types):
142             try:
143                 value = safe_load(value)
144             except (AttributeError, ParserError, ScannerError):
145                 return
146         if isinstance(value, list):
147             value = tuple(value)
148         return value
149 
150 
151 # Initialize singletons of each type for easy reuse
152 Any = AnyType()
153 Bool = BoolType()
154 Int = IntType()
155 Float = FloatType()
156 String = StringType()
157 Dict = DictType()
158 Sequence = SequenceType()
159 
160 # Mapping for basic types into what their Type is
161 _type_mapping = {
162     bool: Bool,
163     int: Int,
164     float: Float,
165     six.binary_type: String,
166     six.text_type: String,
167     dict: Dict,
168     tuple: Sequence,
169     list: Sequence,
170 }
171 
172 
173 def type_from_value(value):
174     """Fetch Type based on a primitive value"""
175     return _type_mapping[type(value)]
176
```
--- 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/src/sentry/utils/types.py b/src/sentry/utils/types.py
--- a/src/sentry/utils/types.py
+++ b/src/sentry/utils/types.py
@@ -70,8 +70,11 @@
     name = 'boolean'
     default = False
     expected_types = (bool, )
+    compatible_types = six.string_types + six.integer_types
 
     def convert(self, value):
+        if isinstance(value, six.integer_types):
+            return bool(value)
         value = value.lower()
         if value in ('y', 'yes', 't', 'true', '1', 'on'):
             return True

{"golden_diff": "diff --git a/src/sentry/utils/types.py b/src/sentry/utils/types.py\n--- a/src/sentry/utils/types.py\n+++ b/src/sentry/utils/types.py\n@@ -70,8 +70,11 @@\n     name = 'boolean'\n     default = False\n     expected_types = (bool, )\n+    compatible_types = six.string_types + six.integer_types\n \n     def convert(self, value):\n+        if isinstance(value, six.integer_types):\n+            return bool(value)\n         value = value.lower()\n         if value in ('y', 'yes', 't', 'true', '1', 'on'):\n             return True\n", "issue": "After upgrading to 8.21, Sentry upgrade wizard hangs on auth.allow-registration\nWhen upgrading my onpremise installation form 8.20 to 8.21 (using docker-compose), the wizard prompted me to set the \u201cAnonymize Beacon\u201d option. When clicking \u201cContinue\u201d, the following error message pops up:\r\n> An invalid value for (auth.allow-registration) was passed to the server.\r\n\r\nThere was no such option `auth.allow-registration` set in either `sentry.conf.py` or `config.yml`.\r\n\r\nThe call to `https://sentry.example.com/api/0/internal/options/` returned a 400, with the following params:\r\n```\r\nsystem.admin-email: admin@example.com\r\nsystem.url-prefix | https://sentry.example.com\r\nauth.allow-registration | 0\r\nbeacon.anonymous | true\r\n```\r\nI worked around that by resending the request, changing 0 for False. My install is now fine\r\n\r\nRunning `sentry config get auth.allow-registration`, whether before the fix or after, returns:\r\n```\r\n        type: BOOLEAN\r\n from config: <not set>\r\n     current: 0\r\n```\r\nThis looks somehow similar to #5699.\r\n\r\nHope that helps!\n", "before_files": [{"content": "\"\"\"\nsentry.utils.types\n~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2010-2016 by the Sentry Team, see AUTHORS for more details.\n:license: BSD, see LICENSE for more details.\n\"\"\"\nfrom __future__ import absolute_import, print_function\n\nimport six\n\nfrom yaml.parser import ParserError\nfrom yaml.scanner import ScannerError\n\nfrom sentry.utils.yaml import safe_load\n\n__all__ = ('InvalidTypeError', 'Any', 'Bool', 'Int', 'Float', 'String', 'Dict', 'Sequence', )\n\n\nclass InvalidTypeError(TypeError):\n    pass\n\n\nclass Type(object):\n    \"\"\"Base Type that provides type coersion\"\"\"\n    name = ''\n    # Default value to be returned when initializing\n    default = None\n    # Types that do not need to be coerced\n    expected_types = ()\n    # Types that are acceptable for coersion\n    compatible_types = six.string_types\n\n    def __call__(self, value=None):\n        if value is None:\n            return self._default()\n        if self.test(value):\n            return value\n        if isinstance(value, self.compatible_types):\n            rv = self.convert(value)\n            # Make sure convert was able to do the right thing\n            # and give us the type we were expecting\n            if self.test(rv):\n                return rv\n        raise InvalidTypeError('{!r} is not a valid {}'.format(value, repr(self)))\n\n    def convert(self, value):\n        return value\n\n    def _default(self):\n        return self.default\n\n    def test(self, value):\n        \"\"\"Check if the value is the correct type or not\"\"\"\n        return isinstance(value, self.expected_types)\n\n    def __repr__(self):\n        return self.name\n\n\nclass AnyType(Type):\n    \"\"\"A type that accepts any value and does no coersion\"\"\"\n    name = 'any'\n    expected_types = (object, )\n    compatible_types = (object, )\n\n\nclass BoolType(Type):\n    \"Coerce a boolean from a string\"\n    name = 'boolean'\n    default = False\n    expected_types = (bool, )\n\n    def convert(self, value):\n        value = value.lower()\n        if value in ('y', 'yes', 't', 'true', '1', 'on'):\n            return True\n        if value in ('n', 'no', 'f', 'false', '0', 'off'):\n            return False\n\n\nclass IntType(Type):\n    \"\"\"Coerce an integer from a string\"\"\"\n    name = 'integer'\n    default = 0\n    expected_types = six.integer_types\n\n    def convert(self, value):\n        try:\n            return int(value)\n        except ValueError:\n            return\n\n\nclass FloatType(Type):\n    \"\"\"Coerce a float from a string or integer\"\"\"\n    name = 'float'\n    default = 0.0\n    expected_types = (float, )\n    compatible_types = six.string_types + six.integer_types + (float, )\n\n    def convert(self, value):\n        try:\n            return float(value)\n        except ValueError:\n            return\n\n\nclass StringType(Type):\n    \"\"\"String type without any coersion, must be a string\"\"\"\n    name = 'string'\n    default = u''\n    expected_types = six.string_types\n    compatible_types = six.string_types\n\n\nclass DictType(Type):\n    \"\"\"Coerce a dict out of a json/yaml string\"\"\"\n    name = 'dictionary'\n    expected_types = (dict, )\n\n    def _default(self):\n        # make sure we create a fresh dict each time\n        return {}\n\n    def convert(self, value):\n        try:\n            return safe_load(value)\n        except (AttributeError, ParserError, ScannerError):\n            return\n\n\nclass SequenceType(Type):\n    \"\"\"Coerce a tuple out of a json/yaml string or a list\"\"\"\n    name = 'sequence'\n    default = ()\n    expected_types = (tuple, list)\n    compatible_types = six.string_types + (tuple, list)\n\n    def convert(self, value):\n        if isinstance(value, six.string_types):\n            try:\n                value = safe_load(value)\n            except (AttributeError, ParserError, ScannerError):\n                return\n        if isinstance(value, list):\n            value = tuple(value)\n        return value\n\n\n# Initialize singletons of each type for easy reuse\nAny = AnyType()\nBool = BoolType()\nInt = IntType()\nFloat = FloatType()\nString = StringType()\nDict = DictType()\nSequence = SequenceType()\n\n# Mapping for basic types into what their Type is\n_type_mapping = {\n    bool: Bool,\n    int: Int,\n    float: Float,\n    six.binary_type: String,\n    six.text_type: String,\n    dict: Dict,\n    tuple: Sequence,\n    list: Sequence,\n}\n\n\ndef type_from_value(value):\n    \"\"\"Fetch Type based on a primitive value\"\"\"\n    return _type_mapping[type(value)]\n", "path": "src/sentry/utils/types.py"}], "after_files": [{"content": "\"\"\"\nsentry.utils.types\n~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2010-2016 by the Sentry Team, see AUTHORS for more details.\n:license: BSD, see LICENSE for more details.\n\"\"\"\nfrom __future__ import absolute_import, print_function\n\nimport six\n\nfrom yaml.parser import ParserError\nfrom yaml.scanner import ScannerError\n\nfrom sentry.utils.yaml import safe_load\n\n__all__ = ('InvalidTypeError', 'Any', 'Bool', 'Int', 'Float', 'String', 'Dict', 'Sequence', )\n\n\nclass InvalidTypeError(TypeError):\n    pass\n\n\nclass Type(object):\n    \"\"\"Base Type that provides type coersion\"\"\"\n    name = ''\n    # Default value to be returned when initializing\n    default = None\n    # Types that do not need to be coerced\n    expected_types = ()\n    # Types that are acceptable for coersion\n    compatible_types = six.string_types\n\n    def __call__(self, value=None):\n        if value is None:\n            return self._default()\n        if self.test(value):\n            return value\n        if isinstance(value, self.compatible_types):\n            rv = self.convert(value)\n            # Make sure convert was able to do the right thing\n            # and give us the type we were expecting\n            if self.test(rv):\n                return rv\n        raise InvalidTypeError('{!r} is not a valid {}'.format(value, repr(self)))\n\n    def convert(self, value):\n        return value\n\n    def _default(self):\n        return self.default\n\n    def test(self, value):\n        \"\"\"Check if the value is the correct type or not\"\"\"\n        return isinstance(value, self.expected_types)\n\n    def __repr__(self):\n        return self.name\n\n\nclass AnyType(Type):\n    \"\"\"A type that accepts any value and does no coersion\"\"\"\n    name = 'any'\n    expected_types = (object, )\n    compatible_types = (object, )\n\n\nclass BoolType(Type):\n    \"Coerce a boolean from a string\"\n    name = 'boolean'\n    default = False\n    expected_types = (bool, )\n    compatible_types = six.string_types + six.integer_types\n\n    def convert(self, value):\n        if isinstance(value, six.integer_types):\n            return bool(value)\n        value = value.lower()\n        if value in ('y', 'yes', 't', 'true', '1', 'on'):\n            return True\n        if value in ('n', 'no', 'f', 'false', '0', 'off'):\n            return False\n\n\nclass IntType(Type):\n    \"\"\"Coerce an integer from a string\"\"\"\n    name = 'integer'\n    default = 0\n    expected_types = six.integer_types\n\n    def convert(self, value):\n        try:\n            return int(value)\n        except ValueError:\n            return\n\n\nclass FloatType(Type):\n    \"\"\"Coerce a float from a string or integer\"\"\"\n    name = 'float'\n    default = 0.0\n    expected_types = (float, )\n    compatible_types = six.string_types + six.integer_types + (float, )\n\n    def convert(self, value):\n        try:\n            return float(value)\n        except ValueError:\n            return\n\n\nclass StringType(Type):\n    \"\"\"String type without any coersion, must be a string\"\"\"\n    name = 'string'\n    default = u''\n    expected_types = six.string_types\n    compatible_types = six.string_types\n\n\nclass DictType(Type):\n    \"\"\"Coerce a dict out of a json/yaml string\"\"\"\n    name = 'dictionary'\n    expected_types = (dict, )\n\n    def _default(self):\n        # make sure we create a fresh dict each time\n        return {}\n\n    def convert(self, value):\n        try:\n            return safe_load(value)\n        except (AttributeError, ParserError, ScannerError):\n            return\n\n\nclass SequenceType(Type):\n    \"\"\"Coerce a tuple out of a json/yaml string or a list\"\"\"\n    name = 'sequence'\n    default = ()\n    expected_types = (tuple, list)\n    compatible_types = six.string_types + (tuple, list)\n\n    def convert(self, value):\n        if isinstance(value, six.string_types):\n            try:\n                value = safe_load(value)\n            except (AttributeError, ParserError, ScannerError):\n                return\n        if isinstance(value, list):\n            value = tuple(value)\n        return value\n\n\n# Initialize singletons of each type for easy reuse\nAny = AnyType()\nBool = BoolType()\nInt = IntType()\nFloat = FloatType()\nString = StringType()\nDict = DictType()\nSequence = SequenceType()\n\n# Mapping for basic types into what their Type is\n_type_mapping = {\n    bool: Bool,\n    int: Int,\n    float: Float,\n    six.binary_type: String,\n    six.text_type: String,\n    dict: Dict,\n    tuple: Sequence,\n    list: Sequence,\n}\n\n\ndef type_from_value(value):\n    \"\"\"Fetch Type based on a primitive value\"\"\"\n    return _type_mapping[type(value)]\n", "path": "src/sentry/utils/types.py"}]}