test_plugin.py 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. import zipfile
  2. from io import BytesIO
  3. from uuid import uuid4
  4. import pytest
  5. from django.core.files.uploadedfile import SimpleUploadedFile
  6. from django.urls import reverse
  7. from sentry.models.debugfile import ProjectDebugFile
  8. from sentry.models.files.file import File
  9. from sentry.testutils.cases import TransactionTestCase
  10. from sentry.testutils.helpers.datetime import before_now, iso_format
  11. from sentry.testutils.relay import RelayStoreHelper
  12. from sentry.utils import json
  13. PROGUARD_UUID = "6dc7fdb0-d2fb-4c8e-9d6b-bb1aa98929b1"
  14. PROGUARD_SOURCE = b"""\
  15. org.slf4j.helpers.Util$ClassContextSecurityManager -> org.a.b.g$a:
  16. 65:65:void <init>() -> <init>
  17. 67:67:java.lang.Class[] getClassContext() -> a
  18. 69:69:java.lang.Class[] getExtraClassContext() -> a
  19. 65:65:void <init>(org.slf4j.helpers.Util$1) -> <init>
  20. """
  21. PROGUARD_INLINE_UUID = "d748e578-b3d1-5be5-b0e5-a42e8c9bf8e0"
  22. PROGUARD_INLINE_SOURCE = b"""\
  23. # compiler: R8
  24. # compiler_version: 2.0.74
  25. # min_api: 16
  26. # pg_map_id: 5b46fdc
  27. # common_typos_disable
  28. $r8$backportedMethods$utility$Objects$2$equals -> a:
  29. boolean equals(java.lang.Object,java.lang.Object) -> a
  30. $r8$twr$utility -> b:
  31. void $closeResource(java.lang.Throwable,java.lang.Object) -> a
  32. android.support.v4.app.RemoteActionCompatParcelizer -> android.support.v4.app.RemoteActionCompatParcelizer:
  33. 1:1:void <init>():11:11 -> <init>
  34. io.sentry.sample.-$$Lambda$r3Avcbztes2hicEObh02jjhQqd4 -> e.a.c.a:
  35. io.sentry.sample.MainActivity f$0 -> b
  36. io.sentry.sample.MainActivity -> io.sentry.sample.MainActivity:
  37. 1:1:void <init>():15:15 -> <init>
  38. 1:1:boolean onCreateOptionsMenu(android.view.Menu):60:60 -> onCreateOptionsMenu
  39. 1:1:boolean onOptionsItemSelected(android.view.MenuItem):69:69 -> onOptionsItemSelected
  40. 2:2:boolean onOptionsItemSelected(android.view.MenuItem):76:76 -> onOptionsItemSelected
  41. 1:1:void bar():54:54 -> t
  42. 1:1:void foo():44 -> t
  43. 1:1:void onClickHandler(android.view.View):40 -> t
  44. """
  45. PROGUARD_BUG_UUID = "071207ac-b491-4a74-957c-2c94fd9594f2"
  46. PROGUARD_BUG_SOURCE = b"x"
  47. JVM_DEBUG_ID = "6dc7fdb0-d2fb-4c8e-9d6b-bb1aa98929b1"
  48. JVM_SOURCE = b"""\
  49. package io.sentry.samples
  50. import android.content.Intent
  51. import android.os.Bundle
  52. import androidx.activity.ComponentActivity
  53. class MainActivity : ComponentActivity() {
  54. override fun onCreate(savedInstanceState: Bundle?) {
  55. super.onCreate(savedInstanceState)
  56. setContentView(R.layout.activity_main)
  57. InnerClass().whoops()
  58. val list = findViewById<RecyclerView>(R.id.list)
  59. list.layoutManager = LinearLayoutManager(this)
  60. list.adapter = TrackAdapter()
  61. }
  62. class InnerClass {
  63. fun whoops() {
  64. AnotherInnerClass().whoops2()
  65. }
  66. }
  67. class AnotherInnerClass {
  68. fun whoops2() {
  69. AdditionalInnerClass().whoops3()
  70. }
  71. }
  72. class AdditionalInnerClass {
  73. fun whoops3() {
  74. throw RuntimeException("whoops")
  75. }
  76. }
  77. }
  78. """
  79. PROGUARD_SOURCE_LOOKUP_UUID = "05d96b1c-1786-477c-8615-d3cf83e027c7"
  80. PROGUARD_SOURCE_LOOKUP_SOURCE = b"""\
  81. io.sentry.samples.instrumentation.ui.EditActivity -> io.sentry.samples.instrumentation.ui.EditActivity:
  82. # {"id":"sourceFile","fileName":"EditActivity.kt"}
  83. int $r8$clinit -> a
  84. 0:65535:void <init>():15:15 -> <init>
  85. 1:6:void onCreate(android.os.Bundle):18:18 -> onCreate
  86. 7:12:void onCreate(android.os.Bundle):19:19 -> onCreate
  87. 13:22:void onCreate(android.os.Bundle):21:21 -> onCreate
  88. 23:32:void onCreate(android.os.Bundle):22:22 -> onCreate
  89. 33:42:void onCreate(android.os.Bundle):23:23 -> onCreate
  90. 43:49:void onCreate(android.os.Bundle):24:24 -> onCreate
  91. 50:71:void onCreate(android.os.Bundle):26:26 -> onCreate
  92. 72:73:java.lang.String io.sentry.samples.instrumentation.data.Track.getName():46:46 -> onCreate
  93. 72:73:void onCreate(android.os.Bundle):28 -> onCreate
  94. 74:76:void onCreate(android.os.Bundle):28:28 -> onCreate
  95. 77:78:java.lang.String io.sentry.samples.instrumentation.data.Track.getComposer():48:48 -> onCreate
  96. 77:78:void onCreate(android.os.Bundle):29 -> onCreate
  97. 79:81:void onCreate(android.os.Bundle):29:29 -> onCreate
  98. 82:83:long io.sentry.samples.instrumentation.data.Track.getMillis():51:51 -> onCreate
  99. 82:83:void onCreate(android.os.Bundle):30 -> onCreate
  100. 84:90:void onCreate(android.os.Bundle):30:30 -> onCreate
  101. 91:92:float io.sentry.samples.instrumentation.data.Track.getPrice():53:53 -> onCreate
  102. 91:92:void onCreate(android.os.Bundle):31 -> onCreate
  103. 93:102:void onCreate(android.os.Bundle):31:31 -> onCreate
  104. 103:119:void onCreate(android.os.Bundle):34:34 -> onCreate
  105. io.sentry.samples.instrumentation.ui.EditActivity$$ExternalSyntheticLambda0 -> io.sentry.samples.instrumentation.ui.g:
  106. # {"id":"sourceFile","fileName":"R8$$SyntheticClass"}
  107. # {"id":"com.android.tools.r8.synthesized"}
  108. android.widget.EditText io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.f$4 -> e
  109. android.widget.EditText io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.f$3 -> d
  110. android.widget.EditText io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.f$2 -> c
  111. io.sentry.samples.instrumentation.data.Track io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.f$0 -> a
  112. android.widget.EditText io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.f$1 -> b
  113. io.sentry.samples.instrumentation.ui.EditActivity io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.f$5 -> f
  114. void io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.<init>(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity) -> <init>
  115. # {"id":"com.android.tools.r8.synthesized"}
  116. 19:21:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):0:0 -> onMenuItemClick
  117. 19:21:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  118. # {"id":"com.android.tools.r8.synthesized"}
  119. 22:35:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):35:35 -> onMenuItemClick
  120. 22:35:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  121. # {"id":"com.android.tools.r8.synthesized"}
  122. 36:44:void io.sentry.samples.instrumentation.ui.AnotherClassInSameFile$AnotherInnerClass.helloOtherInner():26:26 -> onMenuItemClick
  123. 36:44:void io.sentry.samples.instrumentation.ui.AnotherClassInSameFile.otherFun():21 -> onMenuItemClick
  124. 36:44:void io.sentry.samples.instrumentation.ui.AnotherClassInSameFile.helloOther():17 -> onMenuItemClick
  125. 36:44:void io.sentry.samples.instrumentation.ui.SomeService$InnerClassOfSomeService.helloInner():10 -> onMenuItemClick
  126. 36:44:void io.sentry.samples.instrumentation.ui.SomeService.helloThere():5 -> onMenuItemClick
  127. 36:44:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):37 -> onMenuItemClick
  128. 36:44:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  129. # {"id":"com.android.tools.r8.synthesized"}
  130. 45:58:io.sentry.protocol.SentryId io.sentry.Sentry.captureException(java.lang.Throwable):433:433 -> onMenuItemClick
  131. 45:58:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):39 -> onMenuItemClick
  132. 45:58:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  133. # {"id":"com.android.tools.r8.synthesized"}
  134. 59:68:io.sentry.ITransaction io.sentry.Sentry.startTransaction(java.lang.String,java.lang.String,boolean):697:697 -> onMenuItemClick
  135. 59:68:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):42 -> onMenuItemClick
  136. 59:68:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  137. # {"id":"com.android.tools.r8.synthesized"}
  138. 69:71:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):42:42 -> onMenuItemClick
  139. 69:71:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  140. # {"id":"com.android.tools.r8.synthesized"}
  141. 72:79:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):48:48 -> onMenuItemClick
  142. 72:79:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  143. # {"id":"com.android.tools.r8.synthesized"}
  144. 80:87:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):49:49 -> onMenuItemClick
  145. 80:87:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  146. # {"id":"com.android.tools.r8.synthesized"}
  147. 88:95:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):50:50 -> onMenuItemClick
  148. 88:95:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  149. # {"id":"com.android.tools.r8.synthesized"}
  150. 96:103:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):51:51 -> onMenuItemClick
  151. 96:103:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  152. # {"id":"com.android.tools.r8.synthesized"}
  153. 104:125:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):52:52 -> onMenuItemClick
  154. 104:125:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  155. # {"id":"com.android.tools.r8.synthesized"}
  156. 126:142:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):53:53 -> onMenuItemClick
  157. 126:142:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  158. # {"id":"com.android.tools.r8.synthesized"}
  159. 143:164:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):54:54 -> onMenuItemClick
  160. 143:164:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  161. # {"id":"com.android.tools.r8.synthesized"}
  162. 165:175:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):64:64 -> onMenuItemClick
  163. 165:175:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  164. # {"id":"com.android.tools.r8.synthesized"}
  165. 176:187:void io.sentry.samples.instrumentation.ui.EditActivity.addNewTrack(java.lang.String,java.lang.String,long,float):84:84 -> onMenuItemClick
  166. 176:187:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):64 -> onMenuItemClick
  167. 176:187:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  168. # {"id":"com.android.tools.r8.synthesized"}
  169. 188:190:void io.sentry.samples.instrumentation.data.Track.<init>(long,java.lang.String,java.lang.Long,java.lang.String,java.lang.Long,java.lang.Long,long,java.lang.Long,float,int,kotlin.jvm.internal.DefaultConstructorMarker):43:43 -> onMenuItemClick
  170. 188:190:void io.sentry.samples.instrumentation.ui.EditActivity.addNewTrack(java.lang.String,java.lang.String,long,float):84 -> onMenuItemClick
  171. 188:190:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):64 -> onMenuItemClick
  172. 188:190:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  173. # {"id":"com.android.tools.r8.synthesized"}
  174. 191:198:void io.sentry.samples.instrumentation.ui.EditActivity.addNewTrack(java.lang.String,java.lang.String,long,float):94:94 -> onMenuItemClick
  175. 191:198:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):64 -> onMenuItemClick
  176. 191:198:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  177. # {"id":"com.android.tools.r8.synthesized"}
  178. 199:211:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):66:66 -> onMenuItemClick
  179. 199:211:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  180. # {"id":"com.android.tools.r8.synthesized"}
  181. 212:227:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):67:67 -> onMenuItemClick
  182. 212:227:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  183. # {"id":"com.android.tools.r8.synthesized"}
  184. 228:238:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):69:69 -> onMenuItemClick
  185. 228:238:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  186. # {"id":"com.android.tools.r8.synthesized"}
  187. 239:250:io.sentry.samples.instrumentation.data.Track io.sentry.samples.instrumentation.data.Track.copy$default(io.sentry.samples.instrumentation.data.Track,long,java.lang.String,java.lang.Long,java.lang.String,java.lang.Long,java.lang.Long,long,java.lang.Long,float,int,java.lang.Object):0:0 -> onMenuItemClick
  188. 239:250:void io.sentry.samples.instrumentation.ui.EditActivity.update(io.sentry.samples.instrumentation.data.Track,java.lang.String,java.lang.String,long,float):100 -> onMenuItemClick
  189. 239:250:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):69 -> onMenuItemClick
  190. 239:250:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  191. # {"id":"com.android.tools.r8.synthesized"}
  192. 251:265:io.sentry.samples.instrumentation.data.Track io.sentry.samples.instrumentation.data.Track.copy(long,java.lang.String,java.lang.Long,java.lang.String,java.lang.Long,java.lang.Long,long,java.lang.Long,float):0:0 -> onMenuItemClick
  193. 251:265:io.sentry.samples.instrumentation.data.Track io.sentry.samples.instrumentation.data.Track.copy$default(io.sentry.samples.instrumentation.data.Track,long,java.lang.String,java.lang.Long,java.lang.String,java.lang.Long,java.lang.Long,long,java.lang.Long,float,int,java.lang.Object):0 -> onMenuItemClick
  194. 251:265:void io.sentry.samples.instrumentation.ui.EditActivity.update(io.sentry.samples.instrumentation.data.Track,java.lang.String,java.lang.String,long,float):100 -> onMenuItemClick
  195. 251:265:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):69 -> onMenuItemClick
  196. 251:265:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  197. # {"id":"com.android.tools.r8.synthesized"}
  198. 266:273:void io.sentry.samples.instrumentation.ui.EditActivity.update(io.sentry.samples.instrumentation.data.Track,java.lang.String,java.lang.String,long,float):106:106 -> onMenuItemClick
  199. 266:273:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):69 -> onMenuItemClick
  200. 266:273:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  201. # {"id":"com.android.tools.r8.synthesized"}
  202. 274:286:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):71:71 -> onMenuItemClick
  203. 274:286:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  204. # {"id":"com.android.tools.r8.synthesized"}
  205. 287:301:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):72:72 -> onMenuItemClick
  206. 287:301:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  207. # {"id":"com.android.tools.r8.synthesized"}
  208. 302:306:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):74:74 -> onMenuItemClick
  209. 302:306:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  210. # {"id":"com.android.tools.r8.synthesized"}
  211. 307:312:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):75:75 -> onMenuItemClick
  212. 307:312:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  213. # {"id":"com.android.tools.r8.synthesized"}
  214. 313:316:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):56:56 -> onMenuItemClick
  215. 313:316:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  216. # {"id":"com.android.tools.r8.synthesized"}
  217. 317:320:boolean io.sentry.samples.instrumentation.ui.EditActivity.onCreate$lambda-1(io.sentry.samples.instrumentation.data.Track,android.widget.EditText,android.widget.EditText,android.widget.EditText,android.widget.EditText,io.sentry.samples.instrumentation.ui.EditActivity,android.view.MenuItem):61:61 -> onMenuItemClick
  218. 317:320:boolean io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0.onMenuItemClick(android.view.MenuItem):0 -> onMenuItemClick
  219. # {"id":"com.android.tools.r8.synthesized"}
  220. """
  221. EDIT_ACTIVITY_SOURCE = b"""\
  222. package io.sentry.samples.instrumentation.ui
  223. import android.os.Bundle
  224. import android.widget.EditText
  225. import android.widget.Toast
  226. import androidx.activity.ComponentActivity
  227. import androidx.appcompat.widget.Toolbar
  228. import io.sentry.Sentry
  229. import io.sentry.SpanStatus
  230. import io.sentry.samples.instrumentation.R
  231. import io.sentry.samples.instrumentation.SampleApp
  232. import io.sentry.samples.instrumentation.data.Track
  233. import kotlinx.coroutines.runBlocking
  234. class EditActivity : ComponentActivity() {
  235. override fun onCreate(savedInstanceState: Bundle?) {
  236. super.onCreate(savedInstanceState)
  237. setContentView(R.layout.activity_edit)
  238. val nameInput = findViewById<EditText>(R.id.track_name)
  239. val composerInput = findViewById<EditText>(R.id.track_composer)
  240. val durationInput = findViewById<EditText>(R.id.track_duration)
  241. val unitPriceInput = findViewById<EditText>(R.id.track_unit_price)
  242. val originalTrack: Track? = intent.getSerializableExtra(TRACK_EXTRA_KEY) as? Track
  243. originalTrack?.run {
  244. nameInput.setText(name)
  245. composerInput.setText(composer)
  246. durationInput.setText(millis.toString())
  247. unitPriceInput.setText(price.toString())
  248. }
  249. findViewById<Toolbar>(R.id.toolbar).setOnMenuItemClickListener {
  250. if (it.itemId == R.id.action_save) {
  251. try {
  252. SomeService().helloThere()
  253. } catch (e: Exception) {
  254. Sentry.captureException(e)
  255. }
  256. val transaction = Sentry.startTransaction(
  257. "Track Interaction",
  258. if (originalTrack == null) "ui.action.add" else "ui.action.edit",
  259. true
  260. )
  261. val name = nameInput.text.toString()
  262. val composer = composerInput.text.toString()
  263. val duration = durationInput.text.toString()
  264. val unitPrice = unitPriceInput.text.toString()
  265. if (name.isEmpty() || composer.isEmpty() ||
  266. duration.isEmpty() || duration.toLongOrNull() == null ||
  267. unitPrice.isEmpty() || unitPrice.toFloatOrNull() == null
  268. ) {
  269. Toast.makeText(
  270. this,
  271. "Some of the inputs are empty or have wrong format " +
  272. "(duration/unitprice not a number)",
  273. Toast.LENGTH_LONG
  274. ).show()
  275. } else {
  276. if (originalTrack == null) {
  277. addNewTrack(name, composer, duration.toLong(), unitPrice.toFloat())
  278. val createCount = SampleApp.analytics.getInt("create_count", 0) + 1
  279. SampleApp.analytics.edit().putInt("create_count", createCount).apply()
  280. } else {
  281. originalTrack.update(name, composer, duration.toLong(), unitPrice.toFloat())
  282. val editCount = SampleApp.analytics.getInt("edit_count", 0) + 1
  283. SampleApp.analytics.edit().putInt("edit_count", editCount).apply()
  284. }
  285. transaction.finish(SpanStatus.OK)
  286. finish()
  287. }
  288. return@setOnMenuItemClickListener true
  289. }
  290. return@setOnMenuItemClickListener false
  291. }
  292. }
  293. private fun addNewTrack(name: String, composer: String, duration: Long, unitPrice: Float) {
  294. val newTrack = Track(
  295. name = name,
  296. albumId = null,
  297. composer = composer,
  298. mediaTypeId = null,
  299. genreId = null,
  300. millis = duration,
  301. bytes = null,
  302. price = unitPrice
  303. )
  304. runBlocking {
  305. SampleApp.database.tracksDao().insert(newTrack)
  306. }
  307. }
  308. private fun Track.update(name: String, composer: String, duration: Long, unitPrice: Float) {
  309. val updatedTrack = copy(
  310. name = name,
  311. composer = composer,
  312. millis = duration,
  313. price = unitPrice
  314. )
  315. runBlocking {
  316. SampleApp.database.tracksDao().update(updatedTrack)
  317. }
  318. }
  319. companion object {
  320. const val TRACK_EXTRA_KEY = "EditActivity.Track"
  321. }
  322. }
  323. """
  324. SOME_SERVICE_SOURCE = b"""\
  325. package io.sentry.samples.instrumentation.ui
  326. class SomeService {
  327. fun helloThere() {
  328. InnerClassOfSomeService().helloInner()
  329. }
  330. class InnerClassOfSomeService {
  331. fun helloInner() {
  332. AnotherClassInSameFile().helloOther()
  333. }
  334. }
  335. }
  336. class AnotherClassInSameFile {
  337. fun helloOther() {
  338. otherFun()
  339. }
  340. private fun otherFun() {
  341. AnotherInnerClass().helloOtherInner()
  342. }
  343. class AnotherInnerClass {
  344. fun helloOtherInner() {
  345. throw RuntimeException("thrown on purpose to test ProGuard Android source context")
  346. }
  347. }
  348. }
  349. """
  350. @pytest.mark.django_db(transaction=True)
  351. class BasicResolvingIntegrationTest(RelayStoreHelper, TransactionTestCase):
  352. def upload_proguard_mapping(self, uuid, mapping_file_content):
  353. url = reverse(
  354. "sentry-api-0-dsym-files",
  355. kwargs={
  356. "organization_slug": self.project.organization.slug,
  357. "project_slug": self.project.slug,
  358. },
  359. )
  360. self.login_as(user=self.user)
  361. out = BytesIO()
  362. f = zipfile.ZipFile(out, "w")
  363. f.writestr("proguard/%s.txt" % uuid, mapping_file_content)
  364. f.writestr("ignored-file.txt", b"This is just some stuff")
  365. f.close()
  366. response = self.client.post(
  367. url,
  368. {
  369. "file": SimpleUploadedFile(
  370. "symbols.zip", out.getvalue(), content_type="application/zip"
  371. )
  372. },
  373. format="multipart",
  374. )
  375. assert response.status_code == 201, response.content
  376. assert len(response.json()) == 1
  377. def test_basic_resolving(self):
  378. self.upload_proguard_mapping(PROGUARD_UUID, PROGUARD_SOURCE)
  379. event_data = {
  380. "user": {"ip_address": "31.172.207.97"},
  381. "extra": {},
  382. "project": self.project.id,
  383. "platform": "java",
  384. "debug_meta": {"images": [{"type": "proguard", "uuid": PROGUARD_UUID}]},
  385. "exception": {
  386. "values": [
  387. {
  388. "stacktrace": {
  389. "frames": [
  390. {
  391. "function": "a",
  392. "abs_path": None,
  393. "module": "org.a.b.g$a",
  394. "filename": None,
  395. "lineno": 67,
  396. },
  397. {
  398. "function": "a",
  399. "abs_path": None,
  400. "module": "org.a.b.g$a",
  401. "filename": None,
  402. "lineno": 69,
  403. },
  404. ]
  405. },
  406. "module": "org.a.b",
  407. "type": "g$a",
  408. "value": "Attempt to invoke virtual method 'org.a.b.g$a.a' on a null object reference",
  409. }
  410. ]
  411. },
  412. "timestamp": iso_format(before_now(seconds=1)),
  413. }
  414. event = self.post_and_retrieve_event(event_data)
  415. if not self.use_relay():
  416. # We measure the number of queries after an initial post,
  417. # because there are many queries polluting the array
  418. # before the actual "processing" happens (like, auth_user)
  419. with self.assertWriteQueries(
  420. {
  421. "nodestore_node": 2,
  422. "sentry_eventuser": 1,
  423. "sentry_groupedmessage": 1,
  424. "sentry_userreport": 1,
  425. }
  426. ):
  427. self.post_and_retrieve_event(event_data)
  428. exc = event.interfaces["exception"].values[0]
  429. bt = exc.stacktrace
  430. frames = bt.frames
  431. assert exc.type == "Util$ClassContextSecurityManager"
  432. assert (
  433. exc.value
  434. == "Attempt to invoke virtual method 'org.slf4j.helpers.Util$ClassContextSecurityManager.getExtraClassContext' on a null object reference"
  435. )
  436. assert exc.module == "org.slf4j.helpers"
  437. assert frames[0].function == "getClassContext"
  438. assert frames[0].module == "org.slf4j.helpers.Util$ClassContextSecurityManager"
  439. assert frames[1].function == "getExtraClassContext"
  440. assert frames[1].module == "org.slf4j.helpers.Util$ClassContextSecurityManager"
  441. assert event.culprit == (
  442. "org.slf4j.helpers.Util$ClassContextSecurityManager " "in getExtraClassContext"
  443. )
  444. def test_resolving_inline(self):
  445. self.upload_proguard_mapping(PROGUARD_INLINE_UUID, PROGUARD_INLINE_SOURCE)
  446. event_data = {
  447. "user": {"ip_address": "31.172.207.97"},
  448. "extra": {},
  449. "project": self.project.id,
  450. "platform": "java",
  451. "debug_meta": {"images": [{"type": "proguard", "uuid": PROGUARD_INLINE_UUID}]},
  452. "exception": {
  453. "values": [
  454. {
  455. "stacktrace": {
  456. "frames": [
  457. {
  458. "function": "onClick",
  459. "abs_path": None,
  460. "module": "e.a.c.a",
  461. "filename": None,
  462. "lineno": 2,
  463. },
  464. {
  465. "function": "t",
  466. "abs_path": None,
  467. "module": "io.sentry.sample.MainActivity",
  468. "filename": "MainActivity.java",
  469. "lineno": 1,
  470. },
  471. ]
  472. },
  473. "module": "org.a.b",
  474. "type": "g$a",
  475. "value": "Oh no",
  476. }
  477. ]
  478. },
  479. "timestamp": iso_format(before_now(seconds=1)),
  480. }
  481. event = self.post_and_retrieve_event(event_data)
  482. if not self.use_relay():
  483. # We measure the number of queries after an initial post,
  484. # because there are many queries polluting the array
  485. # before the actual "processing" happens (like, auth_user)
  486. with self.assertWriteQueries(
  487. {
  488. "nodestore_node": 2,
  489. "sentry_eventuser": 1,
  490. "sentry_groupedmessage": 1,
  491. "sentry_userreport": 1,
  492. }
  493. ):
  494. self.post_and_retrieve_event(event_data)
  495. exc = event.interfaces["exception"].values[0]
  496. bt = exc.stacktrace
  497. frames = bt.frames
  498. assert len(frames) == 4
  499. assert frames[0].function == "onClick"
  500. assert frames[0].module == "io.sentry.sample.-$$Lambda$r3Avcbztes2hicEObh02jjhQqd4"
  501. assert frames[1].filename == "MainActivity.java"
  502. assert frames[1].module == "io.sentry.sample.MainActivity"
  503. assert frames[1].function == "onClickHandler"
  504. assert frames[1].lineno == 40
  505. assert frames[2].function == "foo"
  506. assert frames[2].lineno == 44
  507. assert frames[3].function == "bar"
  508. assert frames[3].lineno == 54
  509. assert frames[3].filename == "MainActivity.java"
  510. assert frames[3].module == "io.sentry.sample.MainActivity"
  511. def test_error_on_resolving(self):
  512. url = reverse(
  513. "sentry-api-0-dsym-files",
  514. kwargs={
  515. "organization_slug": self.project.organization.slug,
  516. "project_slug": self.project.slug,
  517. },
  518. )
  519. self.login_as(user=self.user)
  520. out = BytesIO()
  521. f = zipfile.ZipFile(out, "w")
  522. f.writestr("proguard/%s.txt" % PROGUARD_BUG_UUID, PROGUARD_BUG_SOURCE)
  523. f.close()
  524. response = self.client.post(
  525. url,
  526. {
  527. "file": SimpleUploadedFile(
  528. "symbols.zip", out.getvalue(), content_type="application/zip"
  529. )
  530. },
  531. format="multipart",
  532. )
  533. assert response.status_code == 201, response.content
  534. assert len(response.json()) == 1
  535. event_data = {
  536. "user": {"ip_address": "31.172.207.97"},
  537. "extra": {},
  538. "project": self.project.id,
  539. "platform": "java",
  540. "debug_meta": {"images": [{"type": "proguard", "uuid": PROGUARD_BUG_UUID}]},
  541. "exception": {
  542. "values": [
  543. {
  544. "stacktrace": {
  545. "frames": [
  546. {
  547. "function": "a",
  548. "abs_path": None,
  549. "module": "org.a.b.g$a",
  550. "filename": None,
  551. "lineno": 67,
  552. },
  553. {
  554. "function": "a",
  555. "abs_path": None,
  556. "module": "org.a.b.g$a",
  557. "filename": None,
  558. "lineno": 69,
  559. },
  560. ]
  561. },
  562. "type": "RuntimeException",
  563. "value": "Oh no",
  564. }
  565. ]
  566. },
  567. "timestamp": iso_format(before_now(seconds=1)),
  568. }
  569. event = self.post_and_retrieve_event(event_data)
  570. assert len(event.data["errors"]) == 1
  571. assert event.data["errors"][0] == {
  572. "mapping_uuid": "071207ac-b491-4a74-957c-2c94fd9594f2",
  573. "type": "proguard_missing_lineno",
  574. }
  575. def upload_jvm_bundle(self, debug_id, source_files):
  576. files = {}
  577. for source_file in source_files:
  578. files[f"files/_/_/{source_file}"] = {"url": f"~/{source_file}"}
  579. manifest = {
  580. "org": self.project.organization.slug,
  581. "project": self.project.slug,
  582. "debug_id": debug_id,
  583. "files": files,
  584. }
  585. file_like = BytesIO()
  586. with zipfile.ZipFile(file_like, "w") as zip:
  587. for source_file in source_files:
  588. zip.writestr(f"files/_/_/{source_file}", source_files[source_file])
  589. zip.writestr("manifest.json", json.dumps(manifest))
  590. file_like.seek(0)
  591. file = File.objects.create(name="bundle.zip", type="artifact.bundle")
  592. file.putfile(file_like)
  593. ProjectDebugFile.objects.create(
  594. project_id=self.project.id,
  595. debug_id=debug_id,
  596. file=file,
  597. )
  598. def test_basic_source_lookup(self):
  599. debug_id = str(uuid4())
  600. self.upload_jvm_bundle(debug_id, {"io/sentry/samples/MainActivity.jvm": JVM_SOURCE})
  601. event_data = {
  602. "user": {"ip_address": "31.172.207.97"},
  603. "extra": {},
  604. "project": self.project.id,
  605. "platform": "java",
  606. "debug_meta": {"images": [{"type": "jvm", "debug_id": debug_id}]},
  607. "exception": {
  608. "values": [
  609. {
  610. "stacktrace": {
  611. "frames": [
  612. {
  613. "function": "otherMethod",
  614. "abs_path": "OtherActivity.java",
  615. "module": "OtherActivity",
  616. "filename": "OtherActivity.java",
  617. "lineno": 100,
  618. },
  619. {
  620. "function": "differentMethod",
  621. "abs_path": "DifferentActivity",
  622. "module": "DifferentActivity",
  623. "filename": "DifferentActivity",
  624. "lineno": 200,
  625. },
  626. {
  627. "function": "onCreate",
  628. "abs_path": None,
  629. "module": "io.sentry.samples.MainActivity",
  630. "filename": None,
  631. "lineno": 11,
  632. },
  633. {
  634. "function": "whoops",
  635. "abs_path": "MainActivity.kt",
  636. "module": "io.sentry.samples.MainActivity$InnerClass",
  637. "filename": "MainActivity.kt",
  638. "lineno": 20,
  639. },
  640. {
  641. "function": "whoops2",
  642. "abs_path": None,
  643. "module": "io.sentry.samples.MainActivity$AnotherInnerClass",
  644. "filename": None,
  645. "lineno": 26,
  646. },
  647. {
  648. "function": "whoops3",
  649. "abs_path": "MainActivity.kt",
  650. "module": "io.sentry.samples.MainActivity$AdditionalInnerClass",
  651. "filename": "MainActivity.kt",
  652. "lineno": 32,
  653. },
  654. ]
  655. },
  656. "module": "io.sentry.samples",
  657. "type": "RuntimeException",
  658. "value": "whoops",
  659. }
  660. ]
  661. },
  662. "timestamp": iso_format(before_now(seconds=1)),
  663. }
  664. event = self.post_and_retrieve_event(event_data)
  665. if not self.use_relay():
  666. # We measure the number of queries after an initial post,
  667. # because there are many queries polluting the array
  668. # before the actual "processing" happens (like, auth_user)
  669. with self.assertWriteQueries(
  670. {
  671. "nodestore_node": 2,
  672. "sentry_eventuser": 1,
  673. "sentry_groupedmessage": 1,
  674. "sentry_userreport": 1,
  675. }
  676. ):
  677. self.post_and_retrieve_event(event_data)
  678. exc = event.interfaces["exception"].values[0]
  679. bt = exc.stacktrace
  680. frames = bt.frames
  681. assert exc.type == "RuntimeException"
  682. assert exc.value == "whoops"
  683. assert exc.module == "io.sentry.samples"
  684. assert frames[0].function == "otherMethod"
  685. assert frames[0].module == "OtherActivity"
  686. assert frames[0].lineno == 100
  687. assert frames[0].context_line is None
  688. assert frames[0].pre_context is None
  689. assert frames[0].post_context is None
  690. assert frames[1].function == "differentMethod"
  691. assert frames[1].module == "DifferentActivity"
  692. assert frames[1].lineno == 200
  693. assert frames[1].context_line is None
  694. assert frames[1].pre_context is None
  695. assert frames[1].post_context is None
  696. assert frames[2].function == "onCreate"
  697. assert frames[2].module == "io.sentry.samples.MainActivity"
  698. assert frames[2].lineno == 11
  699. assert frames[2].context_line == " InnerClass().whoops()"
  700. assert frames[2].pre_context == [
  701. "",
  702. "class MainActivity : ComponentActivity() {",
  703. " override fun onCreate(savedInstanceState: Bundle?) {",
  704. " super.onCreate(savedInstanceState)",
  705. " setContentView(R.layout.activity_main)",
  706. ]
  707. assert frames[2].post_context == [
  708. "",
  709. " val list = findViewById<RecyclerView>(R.id.list)",
  710. " list.layoutManager = LinearLayoutManager(this)",
  711. " list.adapter = TrackAdapter()",
  712. " }",
  713. ]
  714. assert frames[3].function == "whoops"
  715. assert frames[3].module == "io.sentry.samples.MainActivity$InnerClass"
  716. assert frames[3].lineno == 20
  717. assert frames[3].context_line == " AnotherInnerClass().whoops2()"
  718. assert frames[3].pre_context == [
  719. " list.adapter = TrackAdapter()",
  720. " }",
  721. "",
  722. " class InnerClass {",
  723. " fun whoops() {",
  724. ]
  725. assert frames[3].post_context == [
  726. " }",
  727. " }",
  728. "",
  729. " class AnotherInnerClass {",
  730. " fun whoops2() {",
  731. ]
  732. assert frames[4].function == "whoops2"
  733. assert frames[4].module == "io.sentry.samples.MainActivity$AnotherInnerClass"
  734. assert frames[4].lineno == 26
  735. assert frames[4].context_line == " AdditionalInnerClass().whoops3()"
  736. assert frames[4].pre_context == [
  737. " }",
  738. " }",
  739. "",
  740. " class AnotherInnerClass {",
  741. " fun whoops2() {",
  742. ]
  743. assert frames[4].post_context == [
  744. " }",
  745. " }",
  746. "",
  747. " class AdditionalInnerClass {",
  748. " fun whoops3() {",
  749. ]
  750. assert frames[5].function == "whoops3"
  751. assert frames[5].module == "io.sentry.samples.MainActivity$AdditionalInnerClass"
  752. assert frames[5].lineno == 32
  753. assert frames[5].context_line == ' throw RuntimeException("whoops")'
  754. assert frames[5].pre_context == [
  755. " }",
  756. " }",
  757. "",
  758. " class AdditionalInnerClass {",
  759. " fun whoops3() {",
  760. ]
  761. assert frames[5].post_context == [" }", " }", "}", "", ""]
  762. def test_source_lookup_with_proguard(self):
  763. self.upload_proguard_mapping(PROGUARD_SOURCE_LOOKUP_UUID, PROGUARD_SOURCE_LOOKUP_SOURCE)
  764. debug_id1 = str(uuid4())
  765. self.upload_jvm_bundle(
  766. debug_id1,
  767. {
  768. "io/sentry/samples/instrumentation/ui/EditActivity.jvm": EDIT_ACTIVITY_SOURCE,
  769. },
  770. )
  771. debug_id2 = str(uuid4())
  772. self.upload_jvm_bundle(
  773. debug_id2,
  774. {
  775. "io/sentry/samples/instrumentation/ui/SomeService.jvm": SOME_SERVICE_SOURCE,
  776. },
  777. )
  778. event_data = {
  779. "user": {"ip_address": "31.172.207.97"},
  780. "extra": {},
  781. "project": self.project.id,
  782. "platform": "java",
  783. "debug_meta": {
  784. "images": [
  785. {
  786. "type": "jvm",
  787. "debug_id": debug_id1,
  788. },
  789. {
  790. "type": "jvm",
  791. "debug_id": debug_id2,
  792. },
  793. {
  794. "type": "jvm",
  795. "debug_id": str(uuid4()),
  796. }, # does not exist
  797. {"type": "proguard", "uuid": PROGUARD_SOURCE_LOOKUP_UUID},
  798. {"type": "proguard", "uuid": str(uuid4())}, # does not exist
  799. ]
  800. },
  801. "exception": {
  802. "values": [
  803. {
  804. "type": "RuntimeException",
  805. "value": "thrown on purpose to test ProGuard Android source context",
  806. "module": "java.lang",
  807. "thread_id": 1,
  808. "stacktrace": {
  809. "frames": [
  810. {
  811. "filename": "ZygoteInit.java",
  812. "function": "main",
  813. "module": "com.android.internal.os.ZygoteInit",
  814. "lineno": 698,
  815. "native": False,
  816. },
  817. {
  818. "filename": "ZygoteInit.java",
  819. "function": "run",
  820. "module": "com.android.internal.os.ZygoteInit$MethodAndArgsCaller",
  821. "lineno": 903,
  822. "native": False,
  823. },
  824. {
  825. "filename": "Method.java",
  826. "function": "invoke",
  827. "module": "java.lang.reflect.Method",
  828. "lineno": 372,
  829. "native": False,
  830. },
  831. {
  832. "filename": "Method.java",
  833. "function": "invoke",
  834. "module": "java.lang.reflect.Method",
  835. "native": True,
  836. },
  837. {
  838. "filename": "ActivityThread.java",
  839. "function": "main",
  840. "module": "android.app.ActivityThread",
  841. "lineno": 5254,
  842. "native": False,
  843. },
  844. {
  845. "filename": "Looper.java",
  846. "function": "loop",
  847. "module": "android.os.Looper",
  848. "lineno": 135,
  849. "native": False,
  850. },
  851. {
  852. "filename": "Handler.java",
  853. "function": "dispatchMessage",
  854. "module": "android.os.Handler",
  855. "lineno": 95,
  856. "native": False,
  857. },
  858. {
  859. "filename": "Handler.java",
  860. "function": "handleCallback",
  861. "module": "android.os.Handler",
  862. "lineno": 739,
  863. "native": False,
  864. },
  865. {
  866. "filename": "View.java",
  867. "function": "run",
  868. "module": "android.view.View$PerformClick",
  869. "lineno": 19866,
  870. "native": False,
  871. },
  872. {
  873. "filename": "View.java",
  874. "function": "performClick",
  875. "module": "android.view.View",
  876. "lineno": 4780,
  877. "native": False,
  878. },
  879. {
  880. "filename": "ActionMenuItemView.java",
  881. "function": "onClick",
  882. "module": "androidx.appcompat.view.menu.ActionMenuItemView",
  883. "lineno": 7,
  884. "native": False,
  885. },
  886. {
  887. "filename": "ActionMenuView.java",
  888. "function": "invokeItem",
  889. "module": "androidx.appcompat.widget.ActionMenuView",
  890. "lineno": 4,
  891. "native": False,
  892. },
  893. {
  894. "filename": "MenuBuilder.java",
  895. "function": "performItemAction",
  896. "module": "androidx.appcompat.view.menu.MenuBuilder",
  897. "lineno": 1,
  898. "native": False,
  899. },
  900. {
  901. "filename": "MenuBuilder.java",
  902. "function": "performItemAction",
  903. "module": "androidx.appcompat.view.menu.MenuBuilder",
  904. "lineno": 4,
  905. "native": False,
  906. },
  907. {
  908. "filename": "MenuItemImpl.java",
  909. "function": "invoke",
  910. "module": "androidx.appcompat.view.menu.MenuItemImpl",
  911. "lineno": 15,
  912. "native": False,
  913. },
  914. {
  915. "filename": "MenuBuilder.java",
  916. "function": "dispatchMenuItemSelected",
  917. "module": "androidx.appcompat.view.menu.MenuBuilder",
  918. "lineno": 5,
  919. "native": False,
  920. },
  921. {
  922. "filename": "ActionMenuView.java",
  923. "function": "onMenuItemSelected",
  924. "module": "androidx.appcompat.widget.ActionMenuView$MenuBuilderCallback",
  925. "lineno": 7,
  926. "native": False,
  927. },
  928. {
  929. "filename": "Toolbar.java",
  930. "function": "onMenuItemClick",
  931. "module": "androidx.appcompat.widget.Toolbar$1",
  932. "lineno": 7,
  933. "native": False,
  934. },
  935. {
  936. "filename": "R8$$SyntheticClass",
  937. "function": "onMenuItemClick",
  938. "module": "io.sentry.samples.instrumentation.ui.g",
  939. "lineno": 40,
  940. "in_app": True,
  941. "native": False,
  942. },
  943. ]
  944. },
  945. }
  946. ]
  947. },
  948. "timestamp": iso_format(before_now(seconds=1)),
  949. }
  950. event = self.post_and_retrieve_event(event_data)
  951. if not self.use_relay():
  952. # We measure the number of queries after an initial post,
  953. # because there are many queries polluting the array
  954. # before the actual "processing" happens (like, auth_user)
  955. with self.assertWriteQueries(
  956. {
  957. "nodestore_node": 2,
  958. "sentry_eventuser": 1,
  959. "sentry_groupedmessage": 1,
  960. "sentry_userreport": 1,
  961. }
  962. ):
  963. self.post_and_retrieve_event(event_data)
  964. exc = event.interfaces["exception"].values[0]
  965. bt = exc.stacktrace
  966. frames = bt.frames
  967. assert exc.type == "RuntimeException"
  968. assert exc.value == "thrown on purpose to test ProGuard Android source context"
  969. assert exc.module == "java.lang"
  970. assert frames[18].function == "onMenuItemClick"
  971. assert (
  972. frames[18].module
  973. == "io.sentry.samples.instrumentation.ui.EditActivity$$InternalSyntheticLambda$1$ebaa538726b99bb77e0f5e7c86443911af17d6e5be2b8771952ae0caa4ff2ac7$0"
  974. )
  975. assert frames[18].lineno == 0
  976. assert frames[18].context_line is None
  977. assert frames[18].pre_context is None
  978. assert frames[18].post_context is None
  979. assert frames[19].function == "onCreate$lambda-1"
  980. assert frames[19].module == "io.sentry.samples.instrumentation.ui.EditActivity"
  981. assert frames[19].lineno == 37
  982. assert frames[19].context_line == " SomeService().helloThere()"
  983. assert frames[19].pre_context == [
  984. " }",
  985. "",
  986. " findViewById<Toolbar>(R.id.toolbar).setOnMenuItemClickListener {",
  987. " if (it.itemId == R.id.action_save) {",
  988. " try {",
  989. ]
  990. assert frames[19].post_context == [
  991. " } catch (e: Exception) {",
  992. " Sentry.captureException(e)",
  993. " }",
  994. "",
  995. " val transaction = Sentry.startTransaction(",
  996. ]
  997. assert frames[20].function == "helloThere"
  998. assert frames[20].module == "io.sentry.samples.instrumentation.ui.SomeService"
  999. assert frames[20].lineno == 5
  1000. assert frames[20].context_line == " InnerClassOfSomeService().helloInner()"
  1001. assert frames[20].pre_context == [
  1002. "package io.sentry.samples.instrumentation.ui",
  1003. "",
  1004. "class SomeService {",
  1005. " fun helloThere() {",
  1006. ]
  1007. assert frames[20].post_context == [
  1008. " }",
  1009. "",
  1010. " class InnerClassOfSomeService {",
  1011. " fun helloInner() {",
  1012. " AnotherClassInSameFile().helloOther()",
  1013. ]
  1014. assert frames[21].function == "helloInner"
  1015. assert (
  1016. frames[21].module
  1017. == "io.sentry.samples.instrumentation.ui.SomeService$InnerClassOfSomeService"
  1018. )
  1019. assert frames[21].lineno == 10
  1020. assert frames[21].context_line == " AnotherClassInSameFile().helloOther()"
  1021. assert frames[21].pre_context == [
  1022. " InnerClassOfSomeService().helloInner()",
  1023. " }",
  1024. "",
  1025. " class InnerClassOfSomeService {",
  1026. " fun helloInner() {",
  1027. ]
  1028. assert frames[21].post_context == [
  1029. " }",
  1030. " }",
  1031. "}",
  1032. "",
  1033. "class AnotherClassInSameFile {",
  1034. ]
  1035. assert frames[22].function == "helloOther"
  1036. assert frames[22].module == "io.sentry.samples.instrumentation.ui.AnotherClassInSameFile"
  1037. assert frames[22].lineno == 17
  1038. assert frames[22].context_line is None
  1039. assert frames[22].pre_context is None
  1040. assert frames[22].post_context is None
  1041. assert frames[23].function == "otherFun"
  1042. assert frames[23].module == "io.sentry.samples.instrumentation.ui.AnotherClassInSameFile"
  1043. assert frames[23].lineno == 21
  1044. assert frames[23].context_line is None
  1045. assert frames[23].pre_context is None
  1046. assert frames[23].post_context is None
  1047. assert frames[24].function == "helloOtherInner"
  1048. assert (
  1049. frames[24].module
  1050. == "io.sentry.samples.instrumentation.ui.AnotherClassInSameFile$AnotherInnerClass"
  1051. )
  1052. assert frames[24].lineno == 26
  1053. assert frames[24].context_line is None
  1054. assert frames[24].pre_context is None
  1055. assert frames[24].post_context is None