Workable / flask-log-request-id

Flask extension to track and log Request-ID headers produced by PaaS like Heroku and load balancers like Amazon ELB
MIT License
113 stars 23 forks source link

init_app should not reference self. #50

Open nickelwound opened 4 years ago

nickelwound commented 4 years ago

This line appears to break the following common pattern:

def create_app():
    """Bootstrap the app. Takes an instance of the Flask obj/app."""
    app = Flask(__name__)
    request_id = RequestID()
    request_id.init_app(app)
    return app

traceback:

    request_id.init_app(app)
  File "/usr/local/lib/python3.7/site-packages/flask_log_request_id/request_id.py", line 84, in init_app
    if self.app.config['LOG_REQUEST_ID_LOG_ALL_REQUESTS']:
AttributeError: 'NoneType' object has no attribute 'config'

When init_app is called, self.app has not been assigned. It should use the passed app object.

arrdem commented 3 years ago

Seems to have been fixed in #38 but not released.