test: Add attachment E2E integration tests#574
Merged
Conversation
SentrySDK.add_attachment() called inside the init() configuration callback was silently lost because the internal SDK wasn't initialized yet. Now, during the callback window, attachments are redirected to options storage and registered with the platform SDK during init. Split attachment storage in SentryOptions into default_attachments (built-in: log, screenshot, view hierarchy — survive clear) and custom_attachments (user-added during callback — ephemeral, consumed at init). On clear_attachments(), only default attachments are restored. Co-Authored-By: Claude <noreply@anthropic.com>
Reuse add_attachment() after platform SDK init for custom attachments, same pattern as NativeSDK. This correctly handles both file-path and bytes attachments instead of only file-path. Co-Authored-By: Claude <noreply@anthropic.com>
…S SDK Bytes attachments added inside the configuration callback were silently dropped on the web platform. The init method appended them to the file_attachments vector instead of routing through add_attachment(), which dispatches file vs bytes attachments correctly. Co-Authored-By: Claude <noreply@anthropic.com>
Default attachments are always file-based (log, screenshot, view hierarchy). Reject bytes attachments with an error to catch misuse early. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Move custom attachment drain to after js_bridge init call, fixing bytes attachments being sent before the bridge is ready. Also normalize comments across all backends and add changelog entry. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Route clear_attachments() through options.clear_custom_attachments() when called inside the configuration callback, consistent with how add_attachment() already handles the is_configuring state. Previously, clear_attachments() would fall through to DisabledSDK (a no-op), leaving previously added custom attachments intact. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the custom-attachment draining logic (iterate, add_attachment, clear) from all four backend init() methods into SentrySDK::init(), right after internal_sdk->init() succeeds. This eliminates identical copy-pasted blocks in NativeSDK, AndroidSDK, CocoaSDK, and JavaScriptSDK, reducing the risk of future inconsistencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously, add_default_attachment would dereference the Ref to check get_path() without first verifying it's non-null, risking a crash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Add `attachment-capture` CLI command that tests all 4 attachment combinations: file and bytes attachments added both in configuration callback and after SDK initialization. Add corresponding Pester test context that verifies each attachment arrives at Sentry with correct name, type, content type, and size. Closes #571 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Verify that no attachment has a blank name, guarding against the regression fixed in #567. Co-Authored-By: Claude <noreply@anthropic.com>
Add comment explaining why attachments are added inside the init config callback — to verify they are retained after SDK initialization. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Verify that file attachments have the expected byte size to catch cases where files are sent empty. Co-Authored-By: Claude <noreply@anthropic.com>
37406cd to
cc5ad32
Compare
In exported builds, res:// files are packed into the PCK/APK and don't exist on the filesystem. Use user:// paths and write the files at runtime so file path attachments work on all platforms. Co-Authored-By: Claude <noreply@anthropic.com>
Base automatically changed from
limbonaut/fix/attachments-in-config-callback
to
main
March 6, 2026 14:08
Explicitly enable attach_log and attach_scene_tree in the test config and assert that godot.log and view-hierarchy.json are present. Screenshot is not tested as it's unavailable in headless mode. Co-Authored-By: Claude <noreply@anthropic.com>
View hierarchy is not yet implemented on Cocoa platforms, so skip the assertion to avoid false failures. Co-Authored-By: Claude <noreply@anthropic.com>
Cocoa platforms don't include view-hierarchy.json, so the expected count and assertion need to account for 5 attachments instead of 6. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Pester v5 evaluates -Skip during Discovery phase, before BeforeAll runs. Since $script:TestSetup.IsCocoa is initialized in BeforeAll, the -Skip parameter was always falsy and the test never skipped. Use an if-return guard inside the It block instead, matching the existing pattern used elsewhere in the file. Co-Authored-By: Claude <noreply@anthropic.com>
jpnurmi
approved these changes
Mar 9, 2026
mujacica
approved these changes
Mar 9, 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.
Add end-to-end integration tests for custom attachments, covering all 4 combinations of attachment type (file path vs bytes) and timing (configuration callback vs after init).
Get-SentryEventAttachmentsAPI helper.This is needed to verify that attachments added both during SDK configuration and at runtime are correctly sent to Sentry. The new
attachment-captureCLI command exercises each path, and the Pester tests assert on name, type, content type, and size._init_sentry()now accepts an optionalCallablefor extra configuration, keeping the existing callers unchanged.Note: file path attachments currently fail due to a known bug being fixed separately. Bytes attachments pass.