feat(options): Add before_send_feedback hook - #1923
Open
limbonaut wants to merge 11 commits into
Open
Conversation
limbonaut
force-pushed
the
limbonaut/feat/before-send-feedback
branch
from
July 27, 2026 16:01
aa9a1b7 to
b861083
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1923 +/- ##
==========================================
+ Coverage 75.77% 75.83% +0.06%
==========================================
Files 93 93
Lines 22101 22122 +21
Branches 3934 3937 +3
==========================================
+ Hits 16746 16776 +30
+ Misses 4469 4462 -7
+ Partials 886 884 -2 🚀 New features to boost your workflow:
|
limbonaut
force-pushed
the
limbonaut/feat/before-send-feedback
branch
from
July 27, 2026 19:43
a267db0 to
6af6aea
Compare
Comment on lines
+1849
to
+1851
| if (!hint && options->before_send_feedback_func) { | ||
| hint = sentry_hint_new(); | ||
| } |
There was a problem hiding this comment.
Bug: If sentry_hint_new() fails due to out-of-memory, a NULL hint is passed to the before_send_feedback_func callback, silently preventing attachments from being added.
Severity: LOW
Suggested Fix
Check the return value of sentry_hint_new(). If it is NULL, either do not invoke the before_send_feedback_func callback to prevent the silent failure, or explicitly document that the hint may be NULL under out-of-memory conditions and attachments will not be possible.
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: src/sentry_core.c#L1849-L1851
Potential issue: In an out-of-memory (OOM) condition, `sentry_hint_new()` can return
`NULL`. The new code at `src/sentry_core.c:1849~1851` does not check for this `NULL`
return value and passes the `NULL` `hint` to the `before_send_feedback_func` callback.
While attachment functions like `sentry_hint_attach_bytes()` are null-safe and will not
crash, they will silently fail to add attachments. This breaks the documented contract
that the hint can be used to add attachments to the feedback event, leading to a silent
loss of functionality during OOM situations.
Did we get this right? 👍 / 👎 to inform future reviews.
before_send_feedback hookbefore_send_feedback hook
|
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.
Adds
sentry_options_set_before_send_feedback, so user feedback can be modified or discarded before it is sent. The hook runs after the local and global scopes have been applied, so the callback sees the same feedback event that would otherwise be sent.before_send_feedbackhook #1921The callback also receives the capture's hint and can attach files to that single feedback. A hint is created for the callback when the caller did not pass one, so this works across all three capture functions. Returning
sentry_value_new_null()discards the feedback and records afeedbackclient report.