fix(core): Fix sourcemap upload when withSentry is used programmatically#6006
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
Plus 12 more 🤖 This preview updates automatically when you update the PR. |
|
@sentry review |
The early return when `config.plugins` was undefined prevented the `_internal.sentryBuildProperties` fallback from being reached. Default to an empty array instead so the fallback chain continues. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@cursor review |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 5083219. Configure here.
| } | ||
| } | ||
|
|
||
| function getSentryPropertiesFromFile() { |
There was a problem hiding this comment.
this seems to be a more general function to read .properties — I think it could go to some sort of utils, for example the code to write properties already exists in packages/core/plugin/src/utils.ts so maybe it should be there as well?
but also feel free to skip it since it doesn't seem to be very related to the purpose of this PR
There was a problem hiding this comment.
Considered this but the upload script is a standalone .js file that runs directly with Node. I'll keep a note to recheck if we can extract a utils for the scripts under https://github.com/getsentry/sentry-react-native/tree/main/packages/core/scripts
alwx
left a comment
There was a problem hiding this comment.
only one small comment regarding the code to read properties — it feels like we could create one file with everything related to reading/writing properties
but again, it's not really important to do that as part of this PR
📢 Type of change
📜 Description
When
withSentryis used programmatically inapp.config.ts, the Expo sourcemap upload script (sentry-expo-upload-sourcemaps) fails because it discovers Sentry config by looking for@sentry/react-native/expoin thepluginsarray ofexpo config --json. Programmatically-applied plugins don't appear in this array.This PR fixes the issue by:
Stashing build-time properties in
config._internal— ThewithSentryplugin now storesorganization,project, andurlinconfig._internal.sentryBuildPropertiesduring config resolution. This field is included inexpo config --jsonoutput but is stripped from the public app manifest (isPublicConfig: truedeletes_internal), so no metadata leaks into production builds.Reading
_internal.sentryBuildPropertiesin the upload script — When the plugin isn't found in thepluginsarray, the script now checksconfig._internal.sentryBuildPropertiesfrom the sameexpo config --jsonresponse.Fallback to
sentry.propertiesfiles — As additional defense-in-depth, the script also tries readingandroid/sentry.propertiesorios/sentry.properties(created duringexpo prebuild).Improved error message — When no config source is found, the error now mentions the
SENTRY_ORG/SENTRY_PROJECT/SENTRY_URLenvironment variable workaround.Resolution chain (in order of priority)
SENTRY_ORG,SENTRY_PROJECT,SENTRY_URL)config.pluginsarrayconfig._internal.sentryBuildProperties(new — fixes the reported issue)sentry.propertiesfiles from prebuild (new — defense-in-depth)💡 Motivation and Context
Follow up to #5303 (comment)
Users following the
withSentrydocumentation forapp.config.tshit this error when uploading sourcemaps for EAS Update:The root cause is that
createRunOncePlugin(used bywithSentry) applies config modifications through Expo's mod system but doesn't add the plugin toconfig.plugins. Theexpo config --jsonoutput therefore lacks the plugin entry, and the upload script can't find it.💚 How did you test it?
_internal.sentryBuildPropertiesfallback,sentry.propertiesfallback, priority ordering, and error messagingapp.config.jsusing programmaticwithSentry, confirmedexpo config --jsonincludes_internal.sentryBuildPropertieswhilepluginsarray does not contain the sentry plugin_internalis stripped from the public config (app manifest) by Expo'sgetConfig({ isPublicConfig: true }), so no metadata ships in the production app📝 Checklist
sendDefaultPIIis enabled🔮 Next steps