GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — refactor(fastapi): use a global dependency for active thread tracking by faizansaiyed123 · Pull Request #7826 · getsentry/sentry-python

Conversation

@faizansaiyed123

@faizansaiyed123 faizansaiyed123 commented Oct 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Ref #7753

Follow-up to #7825.

This PR replaces FastAPI's private routing.get_request_handler monkey patch with an application-level global dependency.

Changes:

  • Patch FastAPI.__init__ to register a Sentry global dependency before user-supplied global dependencies.
  • Use Starlette's HTTPConnection injection so the dependency is safe for FastAPI versions where global dependencies also apply to WebSockets.
  • Move FastAPI-specific transaction naming and http.route setup into the dependency, using FastAPI's effective route context when available.
  • Install the Starlette sync-handler wrapper on the request's Dependant so synchronous endpoints update thread metadata in their actual worker thread.
  • Preserve FastAPI request event processing and streamed request-body handling inside the global dependency.
  • Preserve user-supplied global dependencies.
  • Remove the private get_request_handler patch.

This branch includes #7825 so it can be reviewed end-to-end. Once #7825 is merged, this PR can be rebased/simplified to the dependency-only diff.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@faizansaiyed123
faizansaiyed123 requested a review from a team as a code owner October 2, 2026 03:19
cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@faizansaiyed123
faizansaiyed123 force-pushed the fix/7753-fastapi-global-dependency branch from ffa6378 to c428c6e Compare October 2, 2026 05:45
cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/integrations/fastapi/test_fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@faizansaiyed123 ChatGPT Codex Connector

faizansaiyed123 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

cursor review

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@faizansaiyed123 ChatGPT Codex Connector

faizansaiyed123 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run verbose=true

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot request id: 8939ba6b-1511-41cb-8bd6-5514646cb90c

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cursor

cursor Bot commented Oct 2, 2026

Copy link
Copy Markdown

Bugbot rules debug

No rules were used for this review.

https://cursor.com/docs/bugbot#team-rules

Bugbot request id: 8939ba6b-1511-41cb-8bd6-5514646cb90c

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Oct 2, 2026
View reviewed changes

@cursor cursor Bot left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sentrivana

sentrivana commented Oct 7, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Hey @faizansaiyed123, can you please update your PR now with the current master now that we've merged the thread change?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

faizansaiyed123 added 17 commits October 7, 2026 17:09
@faizansaiyed123
refactor(fastapi): register active thread dependency globally
3c93394
@faizansaiyed123
refactor(fastapi): remove private request handler patch
1b09b1b
@faizansaiyed123
test(fastapi): cover global dependency websocket compatibility
2f20f37
@faizansaiyed123
style(fastapi): tidy global dependency setup
ed2f825
@faizansaiyed123
test(fastapi): preserve user global dependencies
1544170
@faizansaiyed123
test(fastapi): fix global dependency test placement
14696bb
@faizansaiyed123
refactor(fastapi): move request setup into global dependency
74f7ec2
@faizansaiyed123
style(fastapi): tidy global dependency signature
1a75d1d
@faizansaiyed123
fix(fastapi): preserve sync endpoint thread tracking
ead2b68
@faizansaiyed123
fix(fastapi): wrap effective route dependant
9521334
@faizansaiyed123
fix(fastapi): use effective dependant for sync routes
ecb4063
@faizansaiyed123
test(fastapi): cover sync thread tracking in prefixed routes
0359de4
@faizansaiyed123
style(fastapi): format thread metadata assertion
8902d6b
@faizansaiyed123
refactor(fastapi): restore request lifecycle in global dependency
45318ba
@faizansaiyed123
refactor(fastapi): simplify request event processor helper
c06dae1
@faizansaiyed123
test(fastapi): cover dependency order and request data
5010b81
@faizansaiyed123
test(fastapi): enable tracing for dependency order check
d1861c9
faizansaiyed123 added 9 commits October 7, 2026 17:15
@faizansaiyed123
test(fastapi): cover dependency order and request data
cbd4e1b
@faizansaiyed123
fix(fastapi): fall back to the routed dependant
2422497
@faizansaiyed123
test(fastapi): cover request data on all supported versions
d5f1df7
@faizansaiyed123
fix(fastapi): install request isolation with integration
40fe65d
@faizansaiyed123
test(fastapi): isolate request event processors
d0b5310
@faizansaiyed123
fix(starlette): reuse ASGI instrumentation for FastAPI
18fb09b
@faizansaiyed123
test(fastapi): verify request processor cleanup
33d32a4
@faizansaiyed123
sync starlette integration with verified PR state
7165336
@faizansaiyed123
sync fastapi tests with verified PR state
3c15006
@faizansaiyed123
faizansaiyed123 force-pushed the fix/7753-fastapi-global-dependency branch from 1e3d9c2 to 3c15006 Compare October 7, 2026 11:56
cursor[bot]
cursor Bot reviewed Oct 7, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3c15006. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread sentry_sdk/integrations/fastapi.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@faizansaiyed123
fix(starlette): prevent duplicate patching
15198cf
@faizansaiyed123

faizansaiyed123 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@sentrivana Updated the PR with the current master after #7825 was merged. I also addressed the duplicate Starlette patching issue found by Bugbot. Thanks for the guidance!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

faizansaiyed123 added 2 commits November 1, 2026 10:41
@faizansaiyed123
style(fastapi): add trailing newline
8a773fc
@faizansaiyed123
Merge latest master into FastAPI active-thread tracking
1e65667
@faizansaiyed123

faizansaiyed123 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@getsentry/owners-python-sdk @sentrivana

Cursor Bugbot has completed successfully with no new issues found.

Could someone with maintainer access please approve the pending CI and Test workflows so they can run on the latest commit?

The previous Test run failed in the Mistral step with HTTP 401 (Invalid API Key). If that failure persists, please verify and update the repository's MISTRAL_API_KEY GitHub Actions secret.

Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

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

Reviewers

@cursor cursor[bot] cursor[bot] left review comments

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@faizansaiyed123 @sentrivana
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.