perf(workflows): Avoid excessive querying in WorkflowEngineRuleSerializer#111942
Merged
Conversation
kcons
commented
Mar 31, 2026
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Missing project crashes workflow serialization
- Changed direct dict indexing to use .get() with a None check to gracefully skip projects that are not returned by get_many_from_cache().
Or push these changes by commenting:
@cursor push fc2aeaafd0
Preview (fc2aeaafd0)
diff --git a/src/sentry/api/serializers/models/rule.py b/src/sentry/api/serializers/models/rule.py
--- a/src/sentry/api/serializers/models/rule.py
+++ b/src/sentry/api/serializers/models/rule.py
@@ -410,7 +410,9 @@
)
projects_by_id = {project.id: project for project in projects}
for workflow_id, project_id in workflows_to_project_ids:
- workflow_to_projects[workflow_id].add(projects_by_id[project_id])
+ project = projects_by_id.get(project_id)
+ if project is not None:
+ workflow_to_projects[workflow_id].add(project)
return workflow_to_projectsThis Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
ceorourke
approved these changes
Mar 31, 2026
Contributor
Backend Test FailuresFailures on
|
dashed
pushed a commit
that referenced
this pull request
Apr 1, 2026
…izer (#111942) The previous logic had us potentially sending 100+ workflow queries, which can add 300ms+ to the request. By only fetching ids, we avoid considerable unnecessary work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.


The previous logic had us potentially sending 100+ workflow queries, which can add 300ms+ to the request.
By only fetching ids, we avoid considerable unnecessary work.