Browse Source

Adjust message handling and add tests for OSS Sentry compatability

James Kiger 2 years ago
parent
commit
b584c4e4c2

+ 27 - 4
events/serializers.py

@@ -132,12 +132,20 @@ class FormattedMessageSerializer(serializers.Serializer):
     formatted = serializers.CharField(
         required=False
     )  # Documented as required, but some Sentry SDKs don't send it
-    messages = serializers.CharField(required=False)
+    message = serializers.CharField(required=False)
     params = serializers.JSONField(required=False)
 
-    def to_internal_value(self, data):
-        value = super().to_internal_value(data)
-        return value.get("formatted", "")
+    def validate(self, attrs):
+        data = super().validate(attrs)
+        if not data.get("formatted") and data.get("params"):
+            params = data["params"]
+            if isinstance(params, list):
+                data["formatted"] = data["message"] % tuple(params)
+            elif isinstance(params, dict):
+                data["formatted"] = data["message"].format(**params)
+            return data
+        # OSS Sentry only keeps unformatted "message" when it creates a formatted message
+        return {key: data[key] for key in data if key != "message"}
 
 
 class MessageField(serializers.CharField):
@@ -248,9 +256,23 @@ class StoreDefaultSerializer(SentrySDKEventSerializer):
     def get_message(self, data):
         """Prefer message over logentry"""
         if "message" in data:
+            if isinstance(data["message"], dict):
+                return (
+                    data["message"].get("formatted")
+                    or data["message"].get("message", "")
+                )
             return data["message"]
         return data.get("logentry", {}).get("message", "")
 
+    def get_logentry(self, data):
+        if "logentry" in data:
+            return data.get("logentry")
+        elif "message" in data:
+            message = data["message"]
+            if isinstance(message, dict):
+                return message
+            return {"formatted": message}
+
     def is_url(self, filename: str) -> bool:
         return filename.startswith(("file:", "http:", "https:", "applewebdata:"))
 
@@ -345,6 +367,7 @@ class StoreDefaultSerializer(SentrySDKEventSerializer):
                 "contexts": contexts,
                 "culprit": culprit,
                 "exception": exception,
+                "logentry": self.get_logentry(data),
                 "metadata": metadata,
                 "message": self.get_message(data),
                 "modules": data.get("modules"),

+ 141 - 0
events/test_data/incoming_events/django_message_params.json

@@ -0,0 +1,141 @@
+{
+  "message": { "message": "Here is a new {foo}", "params": { "foo": "error" } },
+  "level": "info",
+  "event_id": "a968a7f1f494452f96e8be1a017d81ec",
+  "timestamp": "2022-10-11T15:18:38.363000Z",
+  "breadcrumbs": { "values": [] },
+  "transaction": "/message/Z",
+  "contexts": {
+    "trace": {
+      "trace_id": "e5cfa4061b63408c8ffdcf918704e357",
+      "span_id": "aebc3c0e76dc7c6e",
+      "parent_span_id": "a1102070ade944af",
+      "op": "django.view",
+      "description": "message"
+    },
+    "runtime": {
+      "name": "CPython",
+      "version": "3.9.9",
+      "build": "3.9.9 (main, Dec 21 2021, 10:14:07) \n[GCC 10.2.1 20210110]"
+    }
+  },
+  "modules": {
+    "certifi": "2022.9.24",
+    "regex": "2022.9.13",
+    "pytz": "2022.2.1",
+    "setuptools": "59.6.0",
+    "cryptography": "38.0.1",
+    "keyring": "23.9.3",
+    "attrs": "22.1.0",
+    "packaging": "21.3",
+    "pip": "21.2.4",
+    "virtualenv": "20.16.5",
+    "black": "19.10b0",
+    "more-itertools": "8.14.0",
+    "click": "8.0.4",
+    "ipython": "7.16.3",
+    "decorator": "5.1.1",
+    "jsonschema": "4.16.0",
+    "importlib-metadata": "4.12.0",
+    "pexpect": "4.8.0",
+    "traitlets": "4.3.3",
+    "zipp": "3.8.1",
+    "filelock": "3.8.0",
+    "asgiref": "3.4.1",
+    "idna": "3.4",
+    "secretstorage": "3.3.3",
+    "django": "3.2.15",
+    "jaraco.classes": "3.2.3",
+    "pyparsing": "3.0.9",
+    "prompt-toolkit": "3.0.3",
+    "requests": "2.28.1",
+    "pycparser": "2.21",
+    "pygments": "2.13.0",
+    "platformdirs": "2.5.2",
+    "charset-normalizer": "2.1.1",
+    "urllib3": "1.26.12",
+    "six": "1.16.0",
+    "cffi": "1.15.1",
+    "pkginfo": "1.8.3",
+    "typed-ast": "1.5.4",
+    "shellingham": "1.5.0",
+    "appdirs": "1.4.4",
+    "pylev": "1.4.0",
+    "poetry": "1.2.1",
+    "poetry-core": "1.2.0",
+    "html5lib": "1.1",
+    "poetry-plugin-export": "1.0.7",
+    "msgpack": "1.0.4",
+    "cleo": "1.0.0a5",
+    "wheel": "0.37.0",
+    "dulwich": "0.20.46",
+    "sentry-sdk": "0.19.5",
+    "pyrsistent": "0.18.1",
+    "jedi": "0.17.2",
+    "cachecontrol": "0.12.11",
+    "ipdb": "0.12.3",
+    "lockfile": "0.12.2",
+    "tomlkit": "0.11.5",
+    "toml": "0.10.2",
+    "requests-toolbelt": "0.9.1",
+    "pathspec": "0.9.0",
+    "jeepney": "0.8.0",
+    "pickleshare": "0.7.5",
+    "parso": "0.7.1",
+    "ptyprocess": "0.7.0",
+    "webencodings": "0.5.1",
+    "sqlparse": "0.4.3",
+    "distlib": "0.3.6",
+    "crashtest": "0.3.1",
+    "cachy": "0.3.0",
+    "wcwidth": "0.2.5",
+    "backcall": "0.2.0",
+    "ipython-genutils": "0.2.0"
+  },
+  "extra": { "sys.argv": ["./manage.py", "runserver", "0.0.0.0:8001"] },
+  "request": {
+    "url": "http://localhost:8001/message/",
+    "query_string": "",
+    "method": "GET",
+    "env": { "SERVER_NAME": "d55ac65b9f3b", "SERVER_PORT": "8001" },
+    "headers": {
+      "Content-Length": "",
+      "Content-Type": "text/plain",
+      "Host": "localhost:8001",
+      "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0",
+      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
+      "Accept-Language": "en-US,en;q=0.5",
+      "Accept-Encoding": "gzip, deflate, br",
+      "Connection": "keep-alive",
+      "Cookie": "",
+      "Upgrade-Insecure-Requests": "1",
+      "Sec-Fetch-Dest": "document",
+      "Sec-Fetch-Mode": "navigate",
+      "Sec-Fetch-Site": "none",
+      "Sec-Fetch-User": "?1"
+    }
+  },
+  "server_name": "d55ac65b9f3b",
+  "sdk": {
+    "name": "sentry.python",
+    "version": "0.19.5",
+    "packages": [{ "name": "pypi:sentry-sdk", "version": "0.19.5" }],
+    "integrations": [
+      "argv",
+      "atexit",
+      "dedupe",
+      "django",
+      "excepthook",
+      "logging",
+      "modules",
+      "stdlib",
+      "threading"
+    ]
+  },
+  "platform": "python",
+  "_meta": {
+    "request": {
+      "headers": { "Cookie": { "": { "rem": [["!config", "x", 0, 1357]] } } }
+    }
+  }
+}

+ 55 - 0
events/test_data/incoming_events/php_message_event.json

@@ -0,0 +1,55 @@
+{
+  "event_id": "ca2f3e4a95694dfb81c3cbb1eaca4e49",
+  "timestamp": 1664988471.208,
+  "platform": "php",
+  "sdk": { "name": "sentry.php", "version": "3.7.0" },
+  "logger": "php",
+  "transaction": "",
+  "server_name": "9c5a5db68679",
+  "environment": "production",
+  "contexts": {
+    "os": {
+      "name": "Linux",
+      "version": "5.14.0-1051-oem",
+      "build": "#58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022",
+      "kernel_version": "Linux 9c5a5db68679 5.14.0-1051-oem #58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022 x86_64"
+    },
+    "runtime": { "name": "php", "version": "8.1.9" },
+    "user": { "name": "Bob Dylan", "status": "subscriber" }
+  },
+  "request": {
+    "url": "http://localhost:8080/",
+    "method": "GET",
+    "headers": {
+      "Cookie": ["[Filtered]"],
+      "Accept-Language": ["en-US,en;q=0.9"],
+      "Accept-Encoding": ["gzip, deflate, br"],
+      "Sec-Fetch-Dest": ["document"],
+      "Sec-Fetch-User": ["?1"],
+      "Sec-Fetch-Mode": ["navigate"],
+      "Sec-Fetch-Site": ["none"],
+      "Accept": [
+        "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
+      ],
+      "User-Agent": [
+        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
+      ],
+      "Upgrade-Insecure-Requests": ["1"],
+      "Sec-Ch-Ua-Platform": ["\"Linux\""],
+      "Sec-Ch-Ua-Mobile": ["?0"],
+      "Sec-Ch-Ua": [
+        "\"Google Chrome\";v=\"105\", \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"105\""
+      ],
+      "Cache-Control": ["max-age=0"],
+      "Connection": ["keep-alive"],
+      "Host": ["localhost:8080"],
+      "Content-Length": [""],
+      "Content-Type": [""]
+    }
+  },
+  "message": {
+    "message": "My raw message with interpreted strings8 like {foo}",
+    "params": { "foo": "this" },
+    "formatted": "My raw message with interpreted strings8 like {foo}"
+  }
+}

+ 189 - 0
events/test_data/oss_sentry_events/django_message_params.json

@@ -0,0 +1,189 @@
+{
+  "eventID": "a968a7f1f494452f96e8be1a017d81ec",
+  "dist": null,
+  "userReport": null,
+  "projectID": "3",
+  "previousEventID": null,
+  "message": "Here is a new error",
+  "id": "73",
+  "size": 3713,
+  "errors": [],
+  "culprit": "/message/Z",
+  "title": "Here is a new error",
+  "platform": "python",
+  "location": null,
+  "nextEventID": null,
+  "type": "default",
+  "metadata": { "title": "Here is a new error" },
+  "groupingConfig": { "id": "legacy:2019-03-12" },
+  "crashFile": null,
+  "tags": [
+    { "value": "Firefox 105.0", "key": "browser", "_meta": null },
+    { "value": "Firefox", "key": "browser.name", "_meta": null },
+    { "value": "info", "key": "level", "_meta": null },
+    { "value": "Ubuntu", "key": "os.name", "_meta": null },
+    { "value": "CPython 3.9.9", "key": "runtime", "_meta": null },
+    { "value": "CPython", "key": "runtime.name", "_meta": null },
+    { "value": "b25ba1d08e79", "key": "server_name", "_meta": null },
+    { "value": "/message/Z", "key": "transaction", "_meta": null },
+    { "value": "http://localhost:8001/message/", "key": "url", "_meta": null }
+  ],
+  "dateCreated": "2022-10-11T15:18:38.363Z",
+  "dateReceived": "2022-10-11T15:18:38.528Z",
+  "user": null,
+  "entries": [
+    {
+      "type": "message",
+      "data": {
+        "message": "Here is a new {foo}",
+        "params": { "foo": "error" },
+        "formatted": "Here is a new error"
+      }
+    },
+    {
+      "type": "request",
+      "data": {
+        "fragment": "",
+        "cookies": [],
+        "inferredContentType": "text/plain",
+        "env": { "SERVER_NAME": "b25ba1d08e79", "SERVER_PORT": "8001" },
+        "headers": [
+          [
+            "Accept",
+            "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
+          ],
+          ["Accept-Encoding", "gzip, deflate, br"],
+          ["Accept-Language", "en-US,en;q=0.5"],
+          ["Connection", "keep-alive"],
+          ["Content-Length", ""],
+          ["Content-Type", "text/plain"],
+          ["Host", "localhost:8001"],
+          ["Referer", "http://localhost:8001/"],
+          ["Sec-Fetch-Dest", "document"],
+          ["Sec-Fetch-Mode", "navigate"],
+          ["Sec-Fetch-Site", "same-origin"],
+          ["Sec-Fetch-User", "?1"],
+          ["Upgrade-Insecure-Requests", "1"],
+          [
+            "User-Agent",
+            "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0"
+          ]
+        ],
+        "url": "http://localhost:8001/message/",
+        "query": [],
+        "data": null,
+        "method": "GET"
+      }
+    }
+  ],
+  "packages": {
+    "more-itertools": "8.14.0",
+    "platformdirs": "2.5.2",
+    "cffi": "1.15.1",
+    "ipython-genutils": "0.2.0",
+    "packaging": "21.3",
+    "pygments": "2.13.0",
+    "cleo": "1.0.0a5",
+    "pip": "21.2.4",
+    "prompt-toolkit": "3.0.3",
+    "parso": "0.7.1",
+    "jeepney": "0.8.0",
+    "html5lib": "1.1",
+    "appdirs": "1.4.4",
+    "requests-toolbelt": "0.9.1",
+    "regex": "2022.9.13",
+    "sqlparse": "0.4.3",
+    "distlib": "0.3.6",
+    "msgpack": "1.0.4",
+    "crashtest": "0.3.1",
+    "sentry-sdk": "0.19.5",
+    "ipdb": "0.12.3",
+    "six": "1.16.0",
+    "poetry": "1.2.1",
+    "ptyprocess": "0.7.0",
+    "click": "8.0.4",
+    "importlib-metadata": "4.12.0",
+    "jedi": "0.17.2",
+    "traitlets": "4.3.3",
+    "asgiref": "3.4.1",
+    "charset-normalizer": "2.1.1",
+    "cachy": "0.3.0",
+    "pathspec": "0.9.0",
+    "cachecontrol": "0.12.11",
+    "certifi": "2022.9.24",
+    "wheel": "0.37.0",
+    "backcall": "0.2.0",
+    "jsonschema": "4.16.0",
+    "cryptography": "38.0.1",
+    "pycparser": "2.21",
+    "secretstorage": "3.3.3",
+    "urllib3": "1.26.12",
+    "virtualenv": "20.16.5",
+    "webencodings": "0.5.1",
+    "poetry-plugin-export": "1.0.7",
+    "pytz": "2022.2.1",
+    "ipython": "7.16.3",
+    "pexpect": "4.8.0",
+    "jaraco.classes": "3.2.3",
+    "zipp": "3.8.1",
+    "pickleshare": "0.7.5",
+    "decorator": "5.1.1",
+    "filelock": "3.8.0",
+    "dulwich": "0.20.46",
+    "lockfile": "0.12.2",
+    "typed-ast": "1.5.4",
+    "keyring": "23.9.3",
+    "wcwidth": "0.2.5",
+    "django": "3.2.15",
+    "poetry-core": "1.2.0",
+    "pyrsistent": "0.18.1",
+    "pyparsing": "3.0.9",
+    "pylev": "1.4.0",
+    "toml": "0.10.2",
+    "setuptools": "59.6.0",
+    "pkginfo": "1.8.3",
+    "black": "19.10b0",
+    "requests": "2.28.1",
+    "shellingham": "1.5.0",
+    "idna": "3.4",
+    "tomlkit": "0.11.5",
+    "attrs": "22.1.0"
+  },
+  "sdk": {
+    "version": "0.19.5",
+    "name": "sentry.python",
+    "upstream": { "url": null, "isNewer": false, "name": "sentry.python" }
+  },
+  "_meta": {
+    "user": null,
+    "context": null,
+    "entries": {},
+    "contexts": null,
+    "message": null,
+    "packages": null,
+    "tags": {},
+    "sdk": null
+  },
+  "contexts": {
+    "runtime": {
+      "version": "3.9.9",
+      "type": "runtime",
+      "build": "3.9.9 (main, Dec 21 2021, 10:14:07) \n[GCC 10.2.1 20210110]",
+      "name": "CPython"
+    },
+    "os": { "type": "os", "name": "Ubuntu" },
+    "trace": {
+      "description": "message",
+      "parent_span_id": "a1102070ade944af",
+      "trace_id": "e5cfa4061b63408c8ffdcf918704e357",
+      "span_id": "aebc3c0e76dc7c6e",
+      "type": "default",
+      "op": "django.view"
+    },
+    "browser": { "version": "105.0", "type": "browser", "name": "Firefox" }
+  },
+  "fingerprints": ["6585c6be473d334e97c29a955f843790"],
+  "context": { "sys.argv": ["./manage.py", "runserver", "0.0.0.0:8001"] },
+  "release": null,
+  "groupID": "33"
+}

+ 120 - 0
events/test_data/oss_sentry_events/php_message_event.json

@@ -0,0 +1,120 @@
+{
+  "eventID": "ca2f3e4a95694dfb81c3cbb1eaca4e49",
+  "dist": null,
+  "userReport": null,
+  "projectID": "8",
+  "previousEventID": null,
+  "message": "My raw message with interpreted strings8 like {foo}",
+  "id": "54",
+  "size": 2293,
+  "errors": [],
+  "culprit": "http://localhost:8080/",
+  "title": "My raw message with interpreted strings8 like {foo}",
+  "platform": "php",
+  "location": null,
+  "nextEventID": null,
+  "type": "default",
+  "metadata": {
+    "title": "My raw message with interpreted strings8 like {foo}"
+  },
+  "groupingConfig": { "id": "legacy:2019-03-12" },
+  "crashFile": null,
+  "tags": [
+    { "value": "Chrome 105.0.0", "key": "browser", "_meta": null },
+    { "value": "Chrome", "key": "browser.name", "_meta": null },
+    { "value": "production", "key": "environment", "_meta": null },
+    { "value": "error", "key": "level", "_meta": null },
+    { "value": "php", "key": "logger", "_meta": null },
+    { "value": "Linux 5.14.0-1051-oem", "key": "os", "_meta": null },
+    { "value": "Linux", "key": "os.name", "_meta": null },
+    { "value": "php 8.1.9", "key": "runtime", "_meta": null },
+    { "value": "php", "key": "runtime.name", "_meta": null },
+    { "value": "9c5a5db68679", "key": "server_name", "_meta": null },
+    { "value": "http://localhost:8080/", "key": "url", "_meta": null }
+  ],
+  "dateCreated": "2022-10-05T16:47:51.208Z",
+  "dateReceived": "2022-10-05T16:47:51.648Z",
+  "user": null,
+  "entries": [
+    {
+      "type": "message",
+      "data": {
+        "params": { "foo": "this" },
+        "formatted": "My raw message with interpreted strings8 like {foo}"
+      }
+    },
+    {
+      "type": "request",
+      "data": {
+        "fragment": "",
+        "cookies": [["[Filtered]", ""]],
+        "inferredContentType": "",
+        "env": null,
+        "headers": [
+          [
+            "Accept",
+            "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
+          ],
+          ["Accept-Encoding", "gzip, deflate, br"],
+          ["Accept-Language", "en-US,en;q=0.9"],
+          ["Cache-Control", "max-age=0"],
+          ["Connection", "keep-alive"],
+          ["Content-Length", ""],
+          ["Content-Type", ""],
+          ["Host", "localhost:8080"],
+          [
+            "Sec-Ch-Ua",
+            "\"Google Chrome\";v=\"105\", \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"105\""
+          ],
+          ["Sec-Ch-Ua-Mobile", "?0"],
+          ["Sec-Ch-Ua-Platform", "\"Linux\""],
+          ["Sec-Fetch-Dest", "document"],
+          ["Sec-Fetch-Mode", "navigate"],
+          ["Sec-Fetch-Site", "none"],
+          ["Sec-Fetch-User", "?1"],
+          ["Upgrade-Insecure-Requests", "1"],
+          [
+            "User-Agent",
+            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
+          ]
+        ],
+        "url": "http://localhost:8080/",
+        "query": [],
+        "data": null,
+        "method": "GET"
+      }
+    }
+  ],
+  "packages": {},
+  "sdk": {
+    "version": "3.7.0",
+    "name": "sentry.php",
+    "upstream": { "url": null, "isNewer": false, "name": "sentry.php" }
+  },
+  "_meta": {
+    "user": null,
+    "context": null,
+    "entries": {},
+    "contexts": null,
+    "message": null,
+    "packages": null,
+    "tags": {},
+    "sdk": null
+  },
+  "contexts": {
+    "runtime": { "version": "8.1.9", "type": "runtime", "name": "php" },
+    "os": {
+      "kernel_version": "Linux 9c5a5db68679 5.14.0-1051-oem #58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022 x86_64",
+      "version": "5.14.0-1051-oem",
+      "type": "os",
+      "build": "#58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022",
+      "name": "Linux"
+    },
+    "user": { "status": "subscriber", "type": "default", "name": "Bob Dylan" },
+    "browser": { "version": "105.0.0", "type": "browser", "name": "Chrome" }
+  },
+  "fingerprints": ["9e0af6b5399dea62e74cfbe0e61ebc1b"],
+  "context": {},
+  "release": null,
+  "groupID": "27"
+}

+ 178 - 0
events/test_data/oss_sentry_json/django_message_params.json

@@ -0,0 +1,178 @@
+{
+  "event_id": "a968a7f1f494452f96e8be1a017d81ec",
+  "project": 3,
+  "release": null,
+  "dist": null,
+  "platform": "python",
+  "message": "Here is a new error",
+  "datetime": "2022-10-11T15:18:38.363000Z",
+  "time_spent": null,
+  "tags": [
+    ["browser", "Firefox 105.0"],
+    ["browser.name", "Firefox"],
+    ["level", "info"],
+    ["os.name", "Ubuntu"],
+    ["runtime", "CPython 3.9.9"],
+    ["runtime.name", "CPython"],
+    ["server_name", "b25ba1d08e79"],
+    ["transaction", "/message/Z"],
+    ["url", "http://localhost:8001/message/"]
+  ],
+  "contexts": {
+    "runtime": {
+      "version": "3.9.9",
+      "type": "runtime",
+      "name": "CPython",
+      "build": "3.9.9 (main, Dec 21 2021, 10:14:07) \n[GCC 10.2.1 20210110]"
+    },
+    "os": { "version": null, "name": "Ubuntu" },
+    "trace": {
+      "description": "message",
+      "parent_span_id": "a1102070ade944af",
+      "trace_id": "e5cfa4061b63408c8ffdcf918704e357",
+      "op": "django.view",
+      "type": "trace",
+      "span_id": "aebc3c0e76dc7c6e"
+    },
+    "browser": { "version": "105.0", "name": "Firefox" }
+  },
+  "culprit": "/message/Z",
+  "extra": { "sys.argv": ["./manage.py", "runserver", "0.0.0.0:8001"] },
+  "fingerprint": ["{{ default }}"],
+  "grouping_config": { "id": "legacy:2019-03-12" },
+  "hashes": ["6585c6be473d334e97c29a955f843790"],
+  "key_id": "3",
+  "level": "info",
+  "location": null,
+  "logentry": {
+    "message": "Here is a new {foo}",
+    "params": { "foo": "error" },
+    "formatted": "Here is a new error"
+  },
+  "logger": "",
+  "metadata": { "title": "Here is a new error" },
+  "modules": {
+    "more-itertools": "8.14.0",
+    "platformdirs": "2.5.2",
+    "cffi": "1.15.1",
+    "ipython-genutils": "0.2.0",
+    "packaging": "21.3",
+    "pygments": "2.13.0",
+    "cleo": "1.0.0a5",
+    "pip": "21.2.4",
+    "prompt-toolkit": "3.0.3",
+    "parso": "0.7.1",
+    "jeepney": "0.8.0",
+    "html5lib": "1.1",
+    "appdirs": "1.4.4",
+    "requests-toolbelt": "0.9.1",
+    "regex": "2022.9.13",
+    "sqlparse": "0.4.3",
+    "distlib": "0.3.6",
+    "msgpack": "1.0.4",
+    "crashtest": "0.3.1",
+    "sentry-sdk": "0.19.5",
+    "ipdb": "0.12.3",
+    "six": "1.16.0",
+    "poetry": "1.2.1",
+    "ptyprocess": "0.7.0",
+    "click": "8.0.4",
+    "importlib-metadata": "4.12.0",
+    "jedi": "0.17.2",
+    "traitlets": "4.3.3",
+    "asgiref": "3.4.1",
+    "charset-normalizer": "2.1.1",
+    "cachy": "0.3.0",
+    "pathspec": "0.9.0",
+    "cachecontrol": "0.12.11",
+    "certifi": "2022.9.24",
+    "wheel": "0.37.0",
+    "backcall": "0.2.0",
+    "jsonschema": "4.16.0",
+    "cryptography": "38.0.1",
+    "pycparser": "2.21",
+    "secretstorage": "3.3.3",
+    "urllib3": "1.26.12",
+    "virtualenv": "20.16.5",
+    "webencodings": "0.5.1",
+    "poetry-plugin-export": "1.0.7",
+    "pytz": "2022.2.1",
+    "ipython": "7.16.3",
+    "pexpect": "4.8.0",
+    "jaraco.classes": "3.2.3",
+    "zipp": "3.8.1",
+    "pickleshare": "0.7.5",
+    "decorator": "5.1.1",
+    "filelock": "3.8.0",
+    "dulwich": "0.20.46",
+    "lockfile": "0.12.2",
+    "typed-ast": "1.5.4",
+    "keyring": "23.9.3",
+    "wcwidth": "0.2.5",
+    "django": "3.2.15",
+    "poetry-core": "1.2.0",
+    "pyrsistent": "0.18.1",
+    "pyparsing": "3.0.9",
+    "pylev": "1.4.0",
+    "toml": "0.10.2",
+    "setuptools": "59.6.0",
+    "pkginfo": "1.8.3",
+    "black": "19.10b0",
+    "requests": "2.28.1",
+    "shellingham": "1.5.0",
+    "idna": "3.4",
+    "tomlkit": "0.11.5",
+    "attrs": "22.1.0"
+  },
+  "received": 1665501518.528,
+  "request": {
+    "url": "http://localhost:8001/message/",
+    "headers": [
+      [
+        "Accept",
+        "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
+      ],
+      ["Accept-Encoding", "gzip, deflate, br"],
+      ["Accept-Language", "en-US,en;q=0.5"],
+      ["Connection", "keep-alive"],
+      ["Content-Length", ""],
+      ["Content-Type", "text/plain"],
+      ["Host", "localhost:8001"],
+      ["Referer", "http://localhost:8001/"],
+      ["Sec-Fetch-Dest", "document"],
+      ["Sec-Fetch-Mode", "navigate"],
+      ["Sec-Fetch-Site", "same-origin"],
+      ["Sec-Fetch-User", "?1"],
+      ["Upgrade-Insecure-Requests", "1"],
+      [
+        "User-Agent",
+        "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0"
+      ]
+    ],
+    "method": "GET",
+    "env": { "SERVER_NAME": "b25ba1d08e79", "SERVER_PORT": "8001" },
+    "inferred_content_type": "text/plain"
+  },
+  "sdk": {
+    "version": "0.19.5",
+    "name": "sentry.python",
+    "packages": [{ "version": "0.19.5", "name": "pypi:sentry-sdk" }],
+    "integrations": [
+      "argv",
+      "atexit",
+      "dedupe",
+      "django",
+      "excepthook",
+      "logging",
+      "modules",
+      "stdlib",
+      "threading"
+    ]
+  },
+  "timestamp": 1665501518.363,
+  "title": "Here is a new error",
+  "transaction": "/message/Z",
+  "type": "default",
+  "use_rust_normalize": true,
+  "version": "7"
+}

+ 92 - 0
events/test_data/oss_sentry_json/php_message_event.json

@@ -0,0 +1,92 @@
+{
+  "event_id": "ca2f3e4a95694dfb81c3cbb1eaca4e49",
+  "project": 8,
+  "release": null,
+  "dist": null,
+  "platform": "php",
+  "message": "My raw message with interpreted strings8 like {foo}",
+  "datetime": "2022-10-05T16:47:51.208000Z",
+  "time_spent": null,
+  "tags": [
+    ["browser", "Chrome 105.0.0"],
+    ["browser.name", "Chrome"],
+    ["environment", "production"],
+    ["level", "error"],
+    ["logger", "php"],
+    ["os", "Linux 5.14.0-1051-oem"],
+    ["os.name", "Linux"],
+    ["runtime", "php 8.1.9"],
+    ["runtime.name", "php"],
+    ["server_name", "9c5a5db68679"],
+    ["url", "http://localhost:8080/"]
+  ],
+  "contexts": {
+    "runtime": { "version": "8.1.9", "type": "runtime", "name": "php" },
+    "os": {
+      "kernel_version": "Linux 9c5a5db68679 5.14.0-1051-oem #58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022 x86_64",
+      "version": "5.14.0-1051-oem",
+      "type": "os",
+      "name": "Linux",
+      "build": "#58-Ubuntu SMP Fri Aug 26 05:50:00 UTC 2022"
+    },
+    "user": { "status": "subscriber", "type": "user", "name": "Bob Dylan" },
+    "browser": { "version": "105.0.0", "name": "Chrome" }
+  },
+  "culprit": "http://localhost:8080/",
+  "environment": "production",
+  "fingerprint": ["{{ default }}"],
+  "grouping_config": { "id": "legacy:2019-03-12" },
+  "hashes": ["9e0af6b5399dea62e74cfbe0e61ebc1b"],
+  "key_id": "8",
+  "level": "error",
+  "location": null,
+  "logentry": {
+    "params": { "foo": "this" },
+    "formatted": "My raw message with interpreted strings8 like {foo}"
+  },
+  "logger": "php",
+  "metadata": {
+    "title": "My raw message with interpreted strings8 like {foo}"
+  },
+  "received": 1664988471.648,
+  "request": {
+    "url": "http://localhost:8080/",
+    "headers": [
+      [
+        "Accept",
+        "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
+      ],
+      ["Accept-Encoding", "gzip, deflate, br"],
+      ["Accept-Language", "en-US,en;q=0.9"],
+      ["Cache-Control", "max-age=0"],
+      ["Connection", "keep-alive"],
+      ["Content-Length", ""],
+      ["Content-Type", ""],
+      ["Cookie", "[Filtered]"],
+      ["Host", "localhost:8080"],
+      [
+        "Sec-Ch-Ua",
+        "\"Google Chrome\";v=\"105\", \"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"105\""
+      ],
+      ["Sec-Ch-Ua-Mobile", "?0"],
+      ["Sec-Ch-Ua-Platform", "\"Linux\""],
+      ["Sec-Fetch-Dest", "document"],
+      ["Sec-Fetch-Mode", "navigate"],
+      ["Sec-Fetch-Site", "none"],
+      ["Sec-Fetch-User", "?1"],
+      ["Upgrade-Insecure-Requests", "1"],
+      [
+        "User-Agent",
+        "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
+      ]
+    ],
+    "method": "GET"
+  },
+  "sdk": { "version": "3.7.0", "name": "sentry.php" },
+  "timestamp": 1664988471.208,
+  "title": "My raw message with interpreted strings8 like {foo}",
+  "transaction": "",
+  "type": "default",
+  "use_rust_normalize": true,
+  "version": "7"
+}

+ 52 - 0
issues/tests/test_sentry_api_compat.py

@@ -213,6 +213,58 @@ class SentryAPICompatTestCase(GlitchTipTestCase):
             sentry_exception["data"].get("hasSystemFrames"),
         )
 
+    def test_php_message_event(self):
+        sdk_error, sentry_json, sentry_data = self.get_json_test_data(
+            "php_message_event"
+        )
+        res = self.client.post(self.event_store_url, sdk_error, format="json")
+        event = Event.objects.first()
+        self.assertEqual(res.status_code, 200)
+        event_id = res.data["id"]
+
+        event_json = event.event_json()
+        self.assertCompareData(event_json, sentry_json, ["logentry"])
+
+        sentry_data = self.get_json_data(
+            "events/test_data/oss_sentry_events/php_message_event.json"
+        )
+        url = self.get_project_events_detail(event_id)
+        res = self.client.get(url)
+        self.assertEqual(res.status_code, 200)
+
+        self.assertCompareData(
+            res.data,
+            sentry_data,
+            ["message", "title",],
+        )
+        # self.assertEqual(res.data["entries"][1], sentry_data["entries"][0])
+
+    def test_django_message_params(self):
+        sdk_error, sentry_json, sentry_data = self.get_json_test_data(
+            "django_message_params"
+        )
+        res = self.client.post(self.event_store_url, sdk_error, format="json")
+        event = Event.objects.first()
+        self.assertEqual(res.status_code, 200)
+        event_id = res.data["id"]
+
+        event_json = event.event_json()
+        self.assertCompareData(event_json, sentry_json, ["logentry"])
+
+        sentry_data = self.get_json_data(
+            "events/test_data/oss_sentry_events/django_message_params.json"
+        )
+        url = self.get_project_events_detail(event_id)
+        res = self.client.get(url)
+        self.assertEqual(res.status_code, 200)
+
+        self.assertCompareData(
+            res.data,
+            sentry_data,
+            ["message", "title",],
+        )
+        # self.assertEqual(res.data["entries"][1], sentry_data["entries"][0])
+
     def test_csp_event(self):
         # Don't mimic this test, use self.get_jest_test_data instead
         data = mdn_sample_csp

+ 2 - 1
sentry/eventtypes/base.py

@@ -24,9 +24,10 @@ class DefaultEvent(BaseEvent):
         message = strip(
             get_path(data, "logentry", "formatted")
             or get_path(data, "logentry", "message")
+            or get_path(data, "message", "formatted")
             or get_path(data, "message")
         )
-
+        
         if message:
             title = truncatechars(message.splitlines()[0], 100)
         else: