Skip to content

Conversation

jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Jul 21, 2025

Expose minimal envelope API for crash reporters / feedback handlers. Extracted from #1303.

  1. allow reading an envelope from the disk
  2. expose envelope headers (DSN and event ID)
  3. allow submitting the envelope to Sentry

Semi-pseudo example:

int main(int argc, char *argv[])
{
    // 1.
    sentry_envelope_t *envelope = sentry_envelope_read_from_file(argv[1]);

    // 2.
    sentry_value_t dsn = sentry_envelope_get_header(envelope, "dsn");
    sentry_value_t event_id = sentry_envelope_get_header(envelope, "event_id");

    sentry_options_t *options = sentry_options_new();
    sentry_options_set_dsn(options, sentry_value_as_string(dsn));
    sentry_init(options);

    /* ... */

    // 3.
    sentry_capture_envelope(envelope);

    sentry_close();
}

Minimal but complete feedback handler used for integration tests: feedback.c

Copy link

github-actions bot commented Jul 21, 2025

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

Generated by 🚫 dangerJS against fb54090

@jpnurmi jpnurmi changed the title feat: envelope headers and capture feat: read and capture envelopes Jul 22, 2025
jpnurmi added 3 commits July 22, 2025 11:27
D:\a\sentry-native\sentry-native\src\sentry_envelope.c(765,53): error : implicit conversion changes signedness: 'long long' to 'unsigned long long' [-Werror,-Wsign-conversion] [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\cmake0\sentry.vcxproj]
D:\a\sentry-native\sentry-native\src\sentry_envelope.c(786,62): error : implicit conversion changes signedness: 'long long' to 'unsigned long long' [-Werror,-Wsign-conversion] [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\cmake0\sentry.vcxproj]
D:\a\sentry-native\sentry-native\src\sentry_envelope.c(803,61): error : implicit conversion changes signedness: 'long long' to 'unsigned long long' [-Werror,-Wsign-conversion] [C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\cmake0\sentry.vcxproj]
jpnurmi added a commit that referenced this pull request Jul 22, 2025
@jpnurmi jpnurmi marked this pull request as ready for review July 22, 2025 11:27
@jpnurmi jpnurmi requested review from vaind and JoshuaMoelans July 22, 2025 11:27
@jpnurmi jpnurmi force-pushed the feat/raw-envelope-headers branch from a051d7d to a9bf358 Compare July 22, 2025 11:50
jpnurmi added a commit that referenced this pull request Jul 22, 2025
Copy link
Collaborator

@vaind vaind left a comment

Choose a reason for hiding this comment

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

Looks alright to me except for a few potential issues below.

Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com>
@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Jul 25, 2025

Thanks, good catches! 🙏 I added a bunch of invalid test cases, and also the examples listed at https://develop.sentry.dev/sdk/data-model/envelopes/#full-examples

@vaind
Copy link
Collaborator

vaind commented Jul 25, 2025

@sentry review

Copy link
Collaborator

@vaind vaind left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, the code is much more defensive now

@jpnurmi jpnurmi force-pushed the feat/raw-envelope-headers branch from 7f7971b to fb54090 Compare July 25, 2025 08:17
jpnurmi added a commit that referenced this pull request Jul 28, 2025
@JoshuaMoelans JoshuaMoelans mentioned this pull request Jul 28, 2025
21 tasks
Copy link
Member

@JoshuaMoelans JoshuaMoelans left a comment

Choose a reason for hiding this comment

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

LGTM! do you think it makes sense to merge this before merging in the int64 PR (which is currently tied to Logs, but could be merged separately before fully finishing the Logs PR), or should we already have int64 values in this PR?

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Jul 28, 2025

do you think it makes sense to merge this before merging in the int64 PR (which is currently tied to Logs, but could be merged separately before fully finishing the Logs PR), or should we already have int64 values in this PR?

I'd vote for merging int64 support separately. It's needed for multiple things i.e. logs and envelope parsing, but not strictly related to either of them. 😉

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Jul 29, 2025

I'll fix the TODOs when int64 support is available. It's not urgent because Sentry only supports ~100MB payloads at the moment.

@jpnurmi jpnurmi merged commit 2ac959e into master Jul 29, 2025
66 of 67 checks passed
@jpnurmi jpnurmi deleted the feat/raw-envelope-headers branch July 29, 2025 05:54
@jpnurmi jpnurmi mentioned this pull request Jul 29, 2025
7 tasks
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.

3 participants