feat(tests): restore manual pid allowance for capturing events#1053
Merged
Conversation
4f3c513 to
a59a4c5
Compare
a59a4c5 to
365fb15
Compare
Comment on lines
+818
to
+822
| {:ok, owner_pid} -> | ||
| @ownership_server | ||
| |> NimbleOwnership.get_owned(owner_pid, %{}) | ||
| |> Map.get(@collector_key) | ||
|
|
There was a problem hiding this comment.
Bug: The pattern match for NimbleOwnership.fetch_owner/3 is incorrect. It expects {:ok, owner_pid} but receives {:ok, {pid, metadata}}, causing a runtime error in subsequent calls.
Severity: HIGH
Suggested Fix
Update the case statement in find_collector/0. The success clause should pattern match on {:ok, {owner_pid, _metadata}} to correctly extract the owner_pid. The error clause should match {:error, _reason} to correctly handle cases where no owner is found and avoid a CaseClauseError.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: lib/sentry/test.ex#L818-L822
Potential issue: The `find_collector/0` function incorrectly pattern-matches the return
value from `NimbleOwnership.fetch_owner/3`. According to NimbleOwnership v1.0
documentation, `fetch_owner/3` returns `{:ok, {owner_pid, metadata}}`. However, the code
at line 818 matches `{:ok, owner_pid}`, which incorrectly binds the variable `owner_pid`
to the tuple `{actual_pid, metadata}`. This tuple is then passed as the `owner` argument
to `NimbleOwnership.get_owned/3`, which expects a PID, leading to a runtime failure.
Additionally, the `case` statement's error handling clause incorrectly matches `:error`
instead of `{:error, reason}`, which will raise a `CaseClauseError` if no owner is
found. This will cause all event collection in test mode to fail.
Did we get this right? 👍 / 👎 to inform future reviews.
sl0thentr0py
approved these changes
May 13, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1052