Skip to content

falcon integration fails when response.status is an int #8138

Closed

Description

@jap

How do you use Sentry?

Self-hosted/on-premise

Version

2.73.0

Steps to Reproduce

Here's a nice reproducer script:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10,<3.13"
# dependencies = [
#     "falcon==3.1.3",
#     "sentry-sdk==2.73.0",
# ]
# ///
"""Reproduce sentry-sdk 2.73.0 failing on a valid Falcon integer response status.

Run: uv run --script reproduce-sentry-falcon-status.py
Expected: the baseline returns 404; the Sentry-enabled request raises AttributeError.
"""

from __future__ import annotations

import falcon.testing
import sentry_sdk
from sentry_sdk.integrations.falcon import FalconIntegration


class Resource:
    def on_get(self, request: falcon.Request, response: falcon.Response) -> None:
        raise LookupError('missing item')


def handle_missing_item(request, response, error, params):
    response.status = 404
    response.text = 'Not found'


app = falcon.App()
app.add_route('/', Resource())
app.add_error_handler(LookupError, handle_missing_item)
client = falcon.testing.TestClient(app)

result = client.simulate_get('/')
assert result.status_code == 404
print('Without Sentry: 404, as expected', flush=True)

sentry_sdk.init(
    dsn='https://public@example.invalid/1',
    default_integrations=False,
    integrations=[FalconIntegration()],
    transport=lambda event: None,
)
print('With Sentry: making the same request...', flush=True)
client.simulate_get('/')

I'm not sure which versions of falcon are supposed to be supported by the integration, but since version 3, Response.status is allowed to be a string or an int (or a http.HTTPStatus which acts as an int), and since version 4 the same holds for HTTPError/HTTPStatus objects.

Since version 3 there is also the helpful https://falcon.readthedocs.io/en/3.0.0/api/util.html#http-status helper that can convert any supported status attribute (be it str, int or http.HTTPStatus) into an int.

Using this unconditionally would break falcon 2 usage; given that the Sentry Integration docs only mention version 3 that might not be an issue, and falcon 3.0.0 was released 5 years ago.

Expected Result

no error

Actual Result

AttributeError: 'int' object has no attribute 'startswith'

Activity

  1. linear-code commented on Oct 27, 2026

    @linear-code
  2. jap commented on Oct 27, 2026

    @jap
    ContributorAuthor

    (I have a patch which I'm finalising right now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions