Skip to content

Falcon integration does not respect custom exception handlers #1362

Closed

Description

@alexmic

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.5.6

Steps to Reproduce

  1. Attach a custom exception handler:
import marshmallow

def marshmallow_validation_error_handler(req, res, exc, params):
    """Transforms a marshmallow validation error into the appropriate HTTP response."""
    raise falcon.HTTPError(400)

api.add_error_handler(marshmallow.ValidationError, marshmallow_validation_error_handler)
  1. Do an API request that leads to a validation error

Expected Result

The marshmallow exception should not have been reported to Sentry.

Actual Result

The custom exception leads to a 4xx, not a 5xx, yet it is still reported as an unhandled error on Sentry.

Activity

  1. sl0thentr0py commented on Mar 7, 2022

    @sl0thentr0py
    Member

    thx for reporting @alexmic, if you want it fixed sooner, PRs always welcome!

  2. added
    Triaged
    on Oct 23, 2023
  3. khuongduy354 commented on Oct 25, 2023

    @khuongduy354

    I have a question,
    image
    In the docs, Sentry detect if Falcon is in dependencies, I've been looking for the code doing that but haven't found it yet.
    At first, I guess the dependencies detection code is inside the init method
    image
    But after reading class Client and Hub, these just takes integration options parameters, and doesn't do dependencies scan.
    image
    Can you show me where that part is ?

  4. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Oct 25, 2023
  5. sentrivana commented on Oct 25, 2023

    @sentrivana
    Collaborator

    Hey @khuongduy354, you're looking for the setup_integrations function which is called at client setup here:

    self.integrations = setup_integrations(
    These are the specific parts responsible for the detection:
    for import_string in all_import_strings:
    try:
    module, cls = import_string.rsplit(".", 1)
    yield getattr(import_module(module), cls)
    except (DidNotEnable, SyntaxError) as e:
    logger.debug(
    "Did not import default integration %s: %s", import_string, e
    )
    and
    except DidNotEnable as e:
    (An integration raises a special DidNotEnable exception if it fails to import the instrumented library and that tells this code that the library is not installed and the integration for it shouldn't be enabled.)

    But please note that someone's already working on this issue.

  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Oct 25, 2023
  7. szokeasaurusrex commented on Oct 25, 2023

    @szokeasaurusrex
    Member

    We have fixed this issue for Falcon versions 3.0 and above only. In case anyone encounters this same bug in an older Falcon version, please feel free to submit a new issue, referencing this one.

  8. ghost added on Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugIntegration: FalconTriaged

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions