Skip to content

fix(features): Honor registered handlers in batch checks - #123181

Open
cvxluo wants to merge 1 commit into
cvxluo/extract-registered-batch-handler-evaluationfrom
cvxluo/honor-registered-handlers-in-batch-checks
Open

fix(features): Honor registered handlers in batch checks#123181
cvxluo wants to merge 1 commit into
cvxluo/extract-registered-batch-handler-evaluationfrom
cvxluo/honor-registered-handlers-in-batch-checks

Conversation

@cvxluo

@cvxluo cvxluo commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Right now, batch_has only will check flagpole, rather than checking both registered flag handler in getsentry and then flagpole, like has does. This makes it problematic to actually use getsentry and flagpole together — e.g. the org serializer won't check getsentry, which means that flags with api_expose=True will not go through getsentry handlers.

Change this so that for each feature flag called in batch_has, we check whether it has a registered handler first, then batch evaluate everything else.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 31, 2026
@sentry

sentry Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 481 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

Comment thread src/sentry/features/manager.py Outdated
project_results: dict[Project, bool | None] = {}
remaining_projects = set(projects)
# Use the same logic as `has_for_batch` to evaluate the feature for each project in the batch
self._run_registered_handlers_for_batch(

@cvxluo cvxluo Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unfortunately this implementation is a bit awkward. the obvious implementation is just to call has for all the flags we need to check, but the main advantage of batch_has is that we have some shared context (like project and organization) so we can be more efficient. to preserve that i decided to duplicate a decent bit of the logic of has itself

@cvxluo
cvxluo force-pushed the cvxluo/honor-registered-handlers-in-batch-checks branch from 7147bf0 to cfd1ff4 Compare August 31, 2026 18:21
@cvxluo
cvxluo marked this pull request as ready for review August 31, 2026 18:54
@cvxluo
cvxluo requested a review from a team August 31, 2026 18:54

@kenzoengineer kenzoengineer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sure there's some duplicated code but the logic still makes sense to me

Run registered handlers before the entity handler, matching has().

Isolate registered handler failures while evaluating fallthroughs in one entity batch.

Leave unhandled flags absent so serializer fallbacks continue to own configured defaults.

Co-authored-by: Claude <noreply@anthropic.com>
@cvxluo
cvxluo force-pushed the cvxluo/honor-registered-handlers-in-batch-checks branch from cfd1ff4 to 9befbc7 Compare August 31, 2026 23:30

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9befbc7. Configure here.

for project, project_value in project_results.items():
project_key = f"project:{project.id}"
feature_results = registered_results.setdefault(project_key, {})
feature_results[feature_name] = project_value

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Partial project results block fallback

Medium Severity

When a registered handler resolves a feature for only some projects, those values are stored even though remaining projects are still unresolved. If the entity handler then omits those projects, batch_has returns a partial map. Callers that treat a present feature as fully batch-evaluated skip fallback, so unresolved projects never receive an entity or default decision.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9befbc7. Configure here.

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

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants