You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Sebastian Brandt (Jira)" <ji...@apache.org> on 2020/02/05 20:10:00 UTC

[jira] [Created] (AIRFLOW-6740) Setting webserver.proxy_fix_num_proxies raises exception

Sebastian Brandt created AIRFLOW-6740:
-----------------------------------------

             Summary: Setting webserver.proxy_fix_num_proxies raises exception
                 Key: AIRFLOW-6740
                 URL: https://issues.apache.org/jira/browse/AIRFLOW-6740
             Project: Apache Airflow
          Issue Type: Bug
          Components: webserver
    Affects Versions: 1.10.7
            Reporter: Sebastian Brandt
            Assignee: Sebastian Brandt


Following configuration variable always leads to an exception:

{code}
[webserver]
proxy_fix_num_proxies = <any value>
{code}

Exception:

{code}
Error handling request /home                                                                                                                                              
Traceback (most recent call last):                                                                                                                                                                                 
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 135, in handle                                                                                                                      
    self.handle_request(listener, req, client, addr)                                                                                                                                                               
  File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 176, in handle_request                                                                                                              
    respiter = self.wsgi(environ, resp.start_response)                                                                                                                                                             
  File "/usr/local/lib/python3.7/site-packages/werkzeug/middleware/dispatcher.py", line 66, in __call__                                                                                                            
    return app(environ, start_response)                                                                                                                                                                            
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/flask.py", line 70, in sentry_patched_wsgi_app                           
    environ, start_response                                                                                                                  
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/wsgi.py", line 126, in __call__                                       
    reraise(*_capture_exception(hub))                                                                                                        
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/_compat.py", line 57, in reraise                                           
    raise value                                                                                                                      
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/wsgi.py", line 122, in __call__                                             
    _sentry_start_response, start_response, span                                                 
  File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/flask.py", line 69, in <lambda>
    return SentryWsgiMiddleware(lambda *a, **kw: old_app(self, *a, **kw))(                                                                         
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__                                                               
    return self.wsgi_app(environ, start_response)                                                                                                                 
  File "/usr/local/lib/python3.7/site-packages/werkzeug/middleware/proxy_fix.py", line 195, in __call__                                                                       
    x_for = self._get_trusted_comma(self.x_for, environ_get("HTTP_X_FORWARDED_FOR"))                                                                                
  File "/usr/local/lib/python3.7/site-packages/werkzeug/middleware/proxy_fix.py", line 166, in _get_trusted_comma                                              
    if len(values) >= trusted:                                                                                                                                           
TypeError: '>=' not supported between instances of 'int' and 'str'        
{code}

This is because the variable is retrieved as string from the config, which then causes the above TypeError. It was almost fixed in https://github.com/apache/airflow/pull/6901, but forgotten.

Since {{num_proxies}} is set last, (https://github.com/pallets/werkzeug/blob/0.16.1/src/werkzeug/middleware/proxy_fix.py#L88), if someone sets the variable, they will *always* get an exception. The only way of not getting one is to not set the variable. Also, it is nowhere documented and deprected (https://github.com/pallets/werkzeug/blob/0.16.1/src/werkzeug/middleware/proxy_fix.py#L113-L120)

Since the configuration variable was introduces quite recently in https://github.com/apache/airflow/commit/d90ddbd and never worked, it can be safely removed.




--
This message was sent by Atlassian Jira
(v8.3.4#803005)