Skip to content

feat(options): Add before_send_feedback hook - #1923

Open
limbonaut wants to merge 11 commits into
masterfrom
limbonaut/feat/before-send-feedback
Open

feat(options): Add before_send_feedback hook#1923
limbonaut wants to merge 11 commits into
masterfrom
limbonaut/feat/before-send-feedback

Conversation

@limbonaut

@limbonaut limbonaut commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

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.

The 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 a feedback client report.

@limbonaut
limbonaut force-pushed the limbonaut/feat/before-send-feedback branch from aa9a1b7 to b861083 Compare July 27, 2026 16:01
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.83%. Comparing base (86cb8d3) to head (2be903c).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@limbonaut
limbonaut force-pushed the limbonaut/feat/before-send-feedback branch from a267db0 to 6af6aea Compare July 27, 2026 19:43
Comment thread src/sentry_core.c
Comment on lines +1849 to +1851
if (!hint && options->before_send_feedback_func) {
hint = sentry_hint_new();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@limbonaut limbonaut changed the title WIP: feat(options): Add before_send_feedback hook feat(options): Add before_send_feedback hook Jul 27, 2026
@github-actions

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 2be903c

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add before_send_feedback hook

1 participant