prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  SVG static assets broken and not displayed
  Every asset with svg type are displayed as broken in web interface.
  
  ![image](https://user-images.githubusercontent.com/776304/43769623-7422f776-9a3a-11e8-9e0d-d16691e1614c.png)
  
  We installed sentry 9 with python and nginx as proxy on CentOS 7.2
  
  When I look the content-type returned, svg files are not recognized.
  
  ```
  $ curl -v https://sentry/_static/1533634345/sentry/dist/php.svg
  (...)
  < Content-Type: application/octet-stream
  ```
  
  If I check the file on server, the svg is not recognized.
  
  ```
  $ file php.svg 
  php.svg: HTML document, ASCII text, with very long lines, with no line terminators
  ```
  
  If we serve the file directly with nginx, the correct mime type is sent as _image/svg+xml_
  
  
  --- 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/runner/settings.py`
  Content:
  ```
  1 """
  2 sentry.runner.settings
  3 ~~~~~~~~~~~~~~~~~~~~~~
  4 
  5 :copyright: (c) 2015 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 os
  11 import click
  12 
  13 DEFAULT_SETTINGS_MODULE = 'sentry.conf.server'
  14 DEFAULT_SETTINGS_CONF = 'config.yml'
  15 DEFAULT_SETTINGS_OVERRIDE = 'sentry.conf.py'
  16 
  17 
  18 def generate_secret_key():
  19     from django.utils.crypto import get_random_string
  20     chars = u'abcdefghijklmnopqrstuvwxyz0123456789!@#%^&*(-_=+)'
  21     return get_random_string(50, chars)
  22 
  23 
  24 def load_config_template(path, version='default'):
  25     from pkg_resources import resource_string
  26     return resource_string('sentry', 'data/config/%s.%s' % (path, version)).decode('utf8')
  27 
  28 
  29 def generate_settings(dev=False):
  30     """
  31     This command is run when ``default_path`` doesn't exist, or ``init`` is
  32     run and returns a string representing the default data to put into their
  33     settings file.
  34     """
  35     context = {
  36         'secret_key': generate_secret_key(),
  37         'debug_flag': dev,
  38         'mail.backend': 'console' if dev else 'smtp',
  39     }
  40 
  41     py = load_config_template(DEFAULT_SETTINGS_OVERRIDE, 'default') % context
  42     yaml = load_config_template(DEFAULT_SETTINGS_CONF, 'default') % context
  43     return py, yaml
  44 
  45 
  46 def get_sentry_conf():
  47     """
  48     Fetch the SENTRY_CONF value, either from the click context
  49     if available, or SENTRY_CONF environment variable.
  50     """
  51     try:
  52         ctx = click.get_current_context()
  53         return ctx.obj['config']
  54     except (RuntimeError, KeyError, TypeError):
  55         try:
  56             return os.environ['SENTRY_CONF']
  57         except KeyError:
  58             return '~/.sentry'
  59 
  60 
  61 def discover_configs():
  62     """
  63     Discover the locations of three configuration components:
  64      * Config directory (~/.sentry)
  65      * Optional python config file (~/.sentry/sentry.conf.py)
  66      * Optional yaml config (~/.sentry/config.yml)
  67     """
  68     try:
  69         config = os.environ['SENTRY_CONF']
  70     except KeyError:
  71         config = '~/.sentry'
  72 
  73     config = os.path.expanduser(config)
  74 
  75     # This is the old, now deprecated code path where SENTRY_CONF is pointed directly
  76     # to a python file
  77     if config.endswith(('.py', '.conf')) or os.path.isfile(config):
  78         return (os.path.dirname(config), config, None, )
  79 
  80     return (
  81         config, os.path.join(config, DEFAULT_SETTINGS_OVERRIDE),
  82         os.path.join(config, DEFAULT_SETTINGS_CONF),
  83     )
  84 
  85 
  86 def configure(ctx, py, yaml, skip_service_validation=False):
  87     """
  88     Given the two different config files, set up the environment.
  89 
  90     NOTE: Will only execute once, so it's safe to call multiple times.
  91     """
  92     global __installed
  93     if __installed:
  94         return
  95 
  96     # Make sure that our warnings are always displayed
  97     import warnings
  98     warnings.filterwarnings('default', '', Warning, r'^sentry')
  99 
  100     # Add in additional mimetypes that are useful for our static files
  101     # which aren't common in default system registries
  102     import mimetypes
  103     for type, ext in (
  104         ('application/json', 'map'), ('application/font-woff', 'woff'),
  105         ('application/font-woff2', 'woff2'), ('application/vnd.ms-fontobject', 'eot'),
  106         ('application/x-font-ttf', 'ttf'), ('application/x-font-ttf',
  107                                             'ttc'), ('font/opentype', 'otf'),
  108     ):
  109         mimetypes.add_type(type, '.' + ext)
  110 
  111     from .importer import install
  112 
  113     if yaml is None:
  114         # `yaml` will be None when SENTRY_CONF is pointed
  115         # directly to a file, in which case, this file must exist
  116         if not os.path.exists(py):
  117             if ctx:
  118                 raise click.ClickException(
  119                     "Configuration file does not exist. Use 'sentry init' to initialize the file."
  120                 )
  121             raise ValueError(
  122                 "Configuration file does not exist at '%s'" % click.format_filename(py)
  123             )
  124     elif not os.path.exists(yaml) and not os.path.exists(py):
  125         if ctx:
  126             raise click.ClickException(
  127                 "Configuration file does not exist. Use 'sentry init' to initialize the file."
  128             )
  129         raise ValueError("Configuration file does not exist at '%s'" % click.format_filename(yaml))
  130 
  131     # Add autoreload for config.yml file if needed
  132     if yaml is not None and os.path.exists(yaml):
  133         from sentry.utils.uwsgi import reload_on_change
  134         reload_on_change(yaml)
  135 
  136     os.environ['DJANGO_SETTINGS_MODULE'] = 'sentry_config'
  137 
  138     install('sentry_config', py, DEFAULT_SETTINGS_MODULE)
  139 
  140     # HACK: we need to force access of django.conf.settings to
  141     # ensure we don't hit any import-driven recursive behavior
  142     from django.conf import settings
  143     hasattr(settings, 'INSTALLED_APPS')
  144 
  145     from .initializer import initialize_app, on_configure
  146     initialize_app(
  147         {
  148             'config_path': py,
  149             'settings': settings,
  150             'options': yaml,
  151         },
  152         skip_service_validation=skip_service_validation
  153     )
  154     on_configure({'settings': settings})
  155 
  156     __installed = True
  157 
  158 
  159 __installed = False
  160
  ```
  --- 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/src/sentry/runner/settings.py b/src/sentry/runner/settings.py
  --- a/src/sentry/runner/settings.py
  +++ b/src/sentry/runner/settings.py
  @@ -101,10 +101,14 @@
       # which aren't common in default system registries
       import mimetypes
       for type, ext in (
  -        ('application/json', 'map'), ('application/font-woff', 'woff'),
  -        ('application/font-woff2', 'woff2'), ('application/vnd.ms-fontobject', 'eot'),
  -        ('application/x-font-ttf', 'ttf'), ('application/x-font-ttf',
  -                                            'ttc'), ('font/opentype', 'otf'),
  +        ('application/json', 'map'),
  +        ('application/font-woff', 'woff'),
  +        ('application/font-woff2', 'woff2'),
  +        ('application/vnd.ms-fontobject', 'eot'),
  +        ('application/x-font-ttf', 'ttf'),
  +        ('application/x-font-ttf', 'ttc'),
  +        ('font/opentype', 'otf'),
  +        ('image/svg+xml', 'svg'),
       ):
           mimetypes.add_type(type, '.' + ext)
  
verification_info: {"golden_diff": "diff --git a/src/sentry/runner/settings.py b/src/sentry/runner/settings.py\n--- a/src/sentry/runner/settings.py\n+++ b/src/sentry/runner/settings.py\n@@ -101,10 +101,14 @@\n     # which aren't common in default system registries\n     import mimetypes\n     for type, ext in (\n-        ('application/json', 'map'), ('application/font-woff', 'woff'),\n-        ('application/font-woff2', 'woff2'), ('application/vnd.ms-fontobject', 'eot'),\n-        ('application/x-font-ttf', 'ttf'), ('application/x-font-ttf',\n-                                            'ttc'), ('font/opentype', 'otf'),\n+        ('application/json', 'map'),\n+        ('application/font-woff', 'woff'),\n+        ('application/font-woff2', 'woff2'),\n+        ('application/vnd.ms-fontobject', 'eot'),\n+        ('application/x-font-ttf', 'ttf'),\n+        ('application/x-font-ttf', 'ttc'),\n+        ('font/opentype', 'otf'),\n+        ('image/svg+xml', 'svg'),\n     ):\n         mimetypes.add_type(type, '.' + ext)\n", "issue": "SVG static assets broken and not displayed\nEvery asset with svg type are displayed as broken in web interface.\r\n\r\n![image](https://user-images.githubusercontent.com/776304/43769623-7422f776-9a3a-11e8-9e0d-d16691e1614c.png)\r\n\r\nWe installed sentry 9 with python and nginx as proxy on CentOS 7.2\r\n\r\nWhen I look the content-type returned, svg files are not recognized.\r\n\r\n```\r\n$ curl -v https://sentry/_static/1533634345/sentry/dist/php.svg\r\n(...)\r\n< Content-Type: application/octet-stream\r\n```\r\n\r\nIf I check the file on server, the svg is not recognized.\r\n\r\n```\r\n$ file php.svg \r\nphp.svg: HTML document, ASCII text, with very long lines, with no line terminators\r\n```\r\n\r\nIf we serve the file directly with nginx, the correct mime type is sent as _image/svg+xml_\r\n\n", "before_files": [{"content": "\"\"\"\nsentry.runner.settings\n~~~~~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2015 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 os\nimport click\n\nDEFAULT_SETTINGS_MODULE = 'sentry.conf.server'\nDEFAULT_SETTINGS_CONF = 'config.yml'\nDEFAULT_SETTINGS_OVERRIDE = 'sentry.conf.py'\n\n\ndef generate_secret_key():\n    from django.utils.crypto import get_random_string\n    chars = u'abcdefghijklmnopqrstuvwxyz0123456789!@#%^&*(-_=+)'\n    return get_random_string(50, chars)\n\n\ndef load_config_template(path, version='default'):\n    from pkg_resources import resource_string\n    return resource_string('sentry', 'data/config/%s.%s' % (path, version)).decode('utf8')\n\n\ndef generate_settings(dev=False):\n    \"\"\"\n    This command is run when ``default_path`` doesn't exist, or ``init`` is\n    run and returns a string representing the default data to put into their\n    settings file.\n    \"\"\"\n    context = {\n        'secret_key': generate_secret_key(),\n        'debug_flag': dev,\n        'mail.backend': 'console' if dev else 'smtp',\n    }\n\n    py = load_config_template(DEFAULT_SETTINGS_OVERRIDE, 'default') % context\n    yaml = load_config_template(DEFAULT_SETTINGS_CONF, 'default') % context\n    return py, yaml\n\n\ndef get_sentry_conf():\n    \"\"\"\n    Fetch the SENTRY_CONF value, either from the click context\n    if available, or SENTRY_CONF environment variable.\n    \"\"\"\n    try:\n        ctx = click.get_current_context()\n        return ctx.obj['config']\n    except (RuntimeError, KeyError, TypeError):\n        try:\n            return os.environ['SENTRY_CONF']\n        except KeyError:\n            return '~/.sentry'\n\n\ndef discover_configs():\n    \"\"\"\n    Discover the locations of three configuration components:\n     * Config directory (~/.sentry)\n     * Optional python config file (~/.sentry/sentry.conf.py)\n     * Optional yaml config (~/.sentry/config.yml)\n    \"\"\"\n    try:\n        config = os.environ['SENTRY_CONF']\n    except KeyError:\n        config = '~/.sentry'\n\n    config = os.path.expanduser(config)\n\n    # This is the old, now deprecated code path where SENTRY_CONF is pointed directly\n    # to a python file\n    if config.endswith(('.py', '.conf')) or os.path.isfile(config):\n        return (os.path.dirname(config), config, None, )\n\n    return (\n        config, os.path.join(config, DEFAULT_SETTINGS_OVERRIDE),\n        os.path.join(config, DEFAULT_SETTINGS_CONF),\n    )\n\n\ndef configure(ctx, py, yaml, skip_service_validation=False):\n    \"\"\"\n    Given the two different config files, set up the environment.\n\n    NOTE: Will only execute once, so it's safe to call multiple times.\n    \"\"\"\n    global __installed\n    if __installed:\n        return\n\n    # Make sure that our warnings are always displayed\n    import warnings\n    warnings.filterwarnings('default', '', Warning, r'^sentry')\n\n    # Add in additional mimetypes that are useful for our static files\n    # which aren't common in default system registries\n    import mimetypes\n    for type, ext in (\n        ('application/json', 'map'), ('application/font-woff', 'woff'),\n        ('application/font-woff2', 'woff2'), ('application/vnd.ms-fontobject', 'eot'),\n        ('application/x-font-ttf', 'ttf'), ('application/x-font-ttf',\n                                            'ttc'), ('font/opentype', 'otf'),\n    ):\n        mimetypes.add_type(type, '.' + ext)\n\n    from .importer import install\n\n    if yaml is None:\n        # `yaml` will be None when SENTRY_CONF is pointed\n        # directly to a file, in which case, this file must exist\n        if not os.path.exists(py):\n            if ctx:\n                raise click.ClickException(\n                    \"Configuration file does not exist. Use 'sentry init' to initialize the file.\"\n                )\n            raise ValueError(\n                \"Configuration file does not exist at '%s'\" % click.format_filename(py)\n            )\n    elif not os.path.exists(yaml) and not os.path.exists(py):\n        if ctx:\n            raise click.ClickException(\n                \"Configuration file does not exist. Use 'sentry init' to initialize the file.\"\n            )\n        raise ValueError(\"Configuration file does not exist at '%s'\" % click.format_filename(yaml))\n\n    # Add autoreload for config.yml file if needed\n    if yaml is not None and os.path.exists(yaml):\n        from sentry.utils.uwsgi import reload_on_change\n        reload_on_change(yaml)\n\n    os.environ['DJANGO_SETTINGS_MODULE'] = 'sentry_config'\n\n    install('sentry_config', py, DEFAULT_SETTINGS_MODULE)\n\n    # HACK: we need to force access of django.conf.settings to\n    # ensure we don't hit any import-driven recursive behavior\n    from django.conf import settings\n    hasattr(settings, 'INSTALLED_APPS')\n\n    from .initializer import initialize_app, on_configure\n    initialize_app(\n        {\n            'config_path': py,\n            'settings': settings,\n            'options': yaml,\n        },\n        skip_service_validation=skip_service_validation\n    )\n    on_configure({'settings': settings})\n\n    __installed = True\n\n\n__installed = False\n", "path": "src/sentry/runner/settings.py"}], "after_files": [{"content": "\"\"\"\nsentry.runner.settings\n~~~~~~~~~~~~~~~~~~~~~~\n\n:copyright: (c) 2015 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 os\nimport click\n\nDEFAULT_SETTINGS_MODULE = 'sentry.conf.server'\nDEFAULT_SETTINGS_CONF = 'config.yml'\nDEFAULT_SETTINGS_OVERRIDE = 'sentry.conf.py'\n\n\ndef generate_secret_key():\n    from django.utils.crypto import get_random_string\n    chars = u'abcdefghijklmnopqrstuvwxyz0123456789!@#%^&*(-_=+)'\n    return get_random_string(50, chars)\n\n\ndef load_config_template(path, version='default'):\n    from pkg_resources import resource_string\n    return resource_string('sentry', 'data/config/%s.%s' % (path, version)).decode('utf8')\n\n\ndef generate_settings(dev=False):\n    \"\"\"\n    This command is run when ``default_path`` doesn't exist, or ``init`` is\n    run and returns a string representing the default data to put into their\n    settings file.\n    \"\"\"\n    context = {\n        'secret_key': generate_secret_key(),\n        'debug_flag': dev,\n        'mail.backend': 'console' if dev else 'smtp',\n    }\n\n    py = load_config_template(DEFAULT_SETTINGS_OVERRIDE, 'default') % context\n    yaml = load_config_template(DEFAULT_SETTINGS_CONF, 'default') % context\n    return py, yaml\n\n\ndef get_sentry_conf():\n    \"\"\"\n    Fetch the SENTRY_CONF value, either from the click context\n    if available, or SENTRY_CONF environment variable.\n    \"\"\"\n    try:\n        ctx = click.get_current_context()\n        return ctx.obj['config']\n    except (RuntimeError, KeyError, TypeError):\n        try:\n            return os.environ['SENTRY_CONF']\n        except KeyError:\n            return '~/.sentry'\n\n\ndef discover_configs():\n    \"\"\"\n    Discover the locations of three configuration components:\n     * Config directory (~/.sentry)\n     * Optional python config file (~/.sentry/sentry.conf.py)\n     * Optional yaml config (~/.sentry/config.yml)\n    \"\"\"\n    try:\n        config = os.environ['SENTRY_CONF']\n    except KeyError:\n        config = '~/.sentry'\n\n    config = os.path.expanduser(config)\n\n    # This is the old, now deprecated code path where SENTRY_CONF is pointed directly\n    # to a python file\n    if config.endswith(('.py', '.conf')) or os.path.isfile(config):\n        return (os.path.dirname(config), config, None, )\n\n    return (\n        config, os.path.join(config, DEFAULT_SETTINGS_OVERRIDE),\n        os.path.join(config, DEFAULT_SETTINGS_CONF),\n    )\n\n\ndef configure(ctx, py, yaml, skip_service_validation=False):\n    \"\"\"\n    Given the two different config files, set up the environment.\n\n    NOTE: Will only execute once, so it's safe to call multiple times.\n    \"\"\"\n    global __installed\n    if __installed:\n        return\n\n    # Make sure that our warnings are always displayed\n    import warnings\n    warnings.filterwarnings('default', '', Warning, r'^sentry')\n\n    # Add in additional mimetypes that are useful for our static files\n    # which aren't common in default system registries\n    import mimetypes\n    for type, ext in (\n        ('application/json', 'map'),\n        ('application/font-woff', 'woff'),\n        ('application/font-woff2', 'woff2'),\n        ('application/vnd.ms-fontobject', 'eot'),\n        ('application/x-font-ttf', 'ttf'),\n        ('application/x-font-ttf', 'ttc'),\n        ('font/opentype', 'otf'),\n        ('image/svg+xml', 'svg'),\n    ):\n        mimetypes.add_type(type, '.' + ext)\n\n    from .importer import install\n\n    if yaml is None:\n        # `yaml` will be None when SENTRY_CONF is pointed\n        # directly to a file, in which case, this file must exist\n        if not os.path.exists(py):\n            if ctx:\n                raise click.ClickException(\n                    \"Configuration file does not exist. Use 'sentry init' to initialize the file.\"\n                )\n            raise ValueError(\n                \"Configuration file does not exist at '%s'\" % click.format_filename(py)\n            )\n    elif not os.path.exists(yaml) and not os.path.exists(py):\n        if ctx:\n            raise click.ClickException(\n                \"Configuration file does not exist. Use 'sentry init' to initialize the file.\"\n            )\n        raise ValueError(\"Configuration file does not exist at '%s'\" % click.format_filename(yaml))\n\n    # Add autoreload for config.yml file if needed\n    if yaml is not None and os.path.exists(yaml):\n        from sentry.utils.uwsgi import reload_on_change\n        reload_on_change(yaml)\n\n    os.environ['DJANGO_SETTINGS_MODULE'] = 'sentry_config'\n\n    install('sentry_config', py, DEFAULT_SETTINGS_MODULE)\n\n    # HACK: we need to force access of django.conf.settings to\n    # ensure we don't hit any import-driven recursive behavior\n    from django.conf import settings\n    hasattr(settings, 'INSTALLED_APPS')\n\n    from .initializer import initialize_app, on_configure\n    initialize_app(\n        {\n            'config_path': py,\n            'settings': settings,\n            'options': yaml,\n        },\n        skip_service_validation=skip_service_validation\n    )\n    on_configure({'settings': settings})\n\n    __installed = True\n\n\n__installed = False\n", "path": "src/sentry/runner/settings.py"}]}