Skip to content

feat(replays): Query project options directly without going through the project#101605

Merged
cmanallen merged 3 commits into
masterfrom
cmanallen/replays-refactor-project-query
Oct 16, 2025
Merged

feat(replays): Query project options directly without going through the project#101605
cmanallen merged 3 commits into
masterfrom
cmanallen/replays-refactor-project-query

Conversation

@cmanallen

Copy link
Copy Markdown
Member

This is a preparatory pull request so we can eventually being caching these queries in a less memory intensive way.

@cmanallen cmanallen requested a review from a team as a code owner October 16, 2025 16:52
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 16, 2025
cursor[bot]

This comment was marked as outdated.

Comment on lines +241 to +251
project = Project.objects.get_from_cache(id=recording.context["project_id"])
assert isinstance(project, Project)
except Project.DoesNotExist as exc:
logger.warning(
"Recording segment was received for a project that does not exist.",
extra={
"project_id": recording.context["project_id"],
"replay_id": recording.context["replay_id"],
},
)
raise DropEvent("Could not find project.") from exc

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.

Potential bug: Project validation is skipped for replay segments where segment_id != 0, which can cause the occurrence consumer to crash if the project is deleted mid-session.
  • Description: Project existence is only validated for the first replay segment (segment_id == 0). For subsequent segments, if the associated project is deleted, events like hydration errors or rage clicks are still published to a Kafka topic. The downstream occurrence consumer does not handle this case. When it tries to process these messages, it will attempt to fetch the non-existent project using Project.objects.get_from_cache, which raises an unhandled Project.DoesNotExist exception. This will cause the consumer to crash, potentially leading to a message backlog and blocking the processing of other valid occurrences.

  • Suggested fix: Move the project validation logic, which fetches the project object and checks for its existence, outside and before the if recording.context["segment_id"] == 0: conditional. This ensures that the project is validated for every incoming replay segment before any events are published.
    severity: 0.85, confidence: 0.95

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is fine.

@cmanallen cmanallen merged commit a7d1491 into master Oct 16, 2025
67 checks passed
@cmanallen cmanallen deleted the cmanallen/replays-refactor-project-query branch October 16, 2025 19:44
srest2021 added a commit that referenced this pull request Oct 20, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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