Uploaded image for project: 'Apache Airflow'
  1. Apache Airflow
  2. AIRFLOW-6740

Setting webserver.proxy_fix_num_proxies raises exception

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.10.7
    • Fix Version/s: 1.10.10
    • Component/s: webserver
    • Labels:
      None

      Description

      Following configuration variable always leads to an exception:

      [webserver]
      proxy_fix_num_proxies = <any value>
      

      Exception:

      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'        
      

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sebastian.brandt Sebastian Brandt
                Reporter:
                sebastian.brandt Sebastian Brandt
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: