Sentry-python: Add support for falcon 3.0

Created on 6 Mar 2020  Â·  4Comments  Â·  Source: getsentry/sentry-python

Currently, Falcon ≥ 3.0.0-ALPHA is not supported by Sentry.

Falcon 3.0 renames the API class to APP. This trips the Sentry Falcon integration detection: the import of api_helpers is renamed to app_helpers.

https://github.com/getsentry/sentry-python/blob/41120009fa7d6cb88d9219cb20874c9dd705639d/sentry_sdk/integrations/falcon.py#L18-L24

Should be a simple fix, roughly:

 try: 
     import falcon  # type: ignore
     from falcon import __version__ as FALCON_VERSION

     try:  # from L102
         version = tuple(map(int, FALCON_VERSION.split(".")))
     except (ValueError, TypeError):
         raise DidNotEnable("Unparseable Falcon version: {}".format(FALCON_VERSION))

     if version < (3, 0)
         import falcon.api_helpers  # type: ignore
         falcon_helpers = falcon.api_helpers
     else:
         import falcon.app_helpers  # type: ignore
         falcon_helpers = falcon.app_helpers

 except ImportError:
     raise DidNotEnable("Falcon not installed")

and renaming all references to falcon.api_helpers to falcon_helpers.

A quick glance shows that PrepareMiddleware has not changed (returns the same tuple). I can go ahead and open a PR and check if other changes are necessary to support Falcon 3.0 before it comes out of alpha.

enhancement falcon

Most helpful comment

@untitaker Falcon 3.0 was released 6 days ago.

All 4 comments

Feel free to, but I feel like it's wasted time until it comes out of alpha. Preparing support for APIs that change in the next alpha has bitten me in the past.

Fair point, I just looked at the status of the project and it might be a while. Can be picked up in the future.

Falcon 3.0 still hasn't been released so until that happens let's just close this.

@untitaker Falcon 3.0 was released 6 days ago.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robd003 picture robd003  Â·  5Comments

mlennon-lumere picture mlennon-lumere  Â·  4Comments

mumumumu picture mumumumu  Â·  6Comments

miracle2k picture miracle2k  Â·  6Comments

rollcat picture rollcat  Â·  3Comments