From ce97abc044c5934054641b6e82e077ffc12e5b89 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 30 May 2025 15:41:46 +0200 Subject: [PATCH 1/2] fix: gzip compressed envelopes --- sentry-cli/integration-test/sentry-server.py | 3 +++ .../integration-test/tests/action.Tests.ps1 | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/sentry-cli/integration-test/sentry-server.py b/sentry-cli/integration-test/sentry-server.py index e082b2f..2e418ac 100644 --- a/sentry-cli/integration-test/sentry-server.py +++ b/sentry-cli/integration-test/sentry-server.py @@ -8,6 +8,7 @@ import threading import binascii import json +import gzip uri = urlparse(sys.argv[1] if len(sys.argv) > 1 else 'http://127.0.0.1:8000') apiOrg = 'org' @@ -135,6 +136,8 @@ def requestBody(self): if self.command == "POST" and 'Content-Length' in self.headers: length = int(self.headers['Content-Length']) content = self.rfile.read(length) + if self.headers.get("Content-Encoding") == "gzip": + content = gzip.decompress(content) try: return content.decode("utf-8") except: diff --git a/sentry-cli/integration-test/tests/action.Tests.ps1 b/sentry-cli/integration-test/tests/action.Tests.ps1 index 0ec39f5..332c0da 100644 --- a/sentry-cli/integration-test/tests/action.Tests.ps1 +++ b/sentry-cli/integration-test/tests/action.Tests.ps1 @@ -72,4 +72,28 @@ helloworld $result.Envelopes()[0].Length | Should -Be 357 $result.Envelopes()[1].Length | Should -Be 84 } + + It "collects gzip compressed envelopes" { + $result = Invoke-SentryServer { + Param([string]$url) + $ms = New-Object System.IO.MemoryStream + $gzip = New-Object System.IO.Compression.GZipStream($ms, [System.IO.Compression.CompressionMode]::Compress) + $bytes = [System.Text.Encoding]::UTF8.GetBytes(@' +{"event_id":"9ec79c33ec9942ab8353589fcb2e04dc","dsn":"https://e12d836b15bb49d7bbf99e64295d995b:@sentry.io/42"} +{"type":"attachment","length":10,"content_type":"text/plain","filename":"hello.txt"} +\xef\xbb\xbfHello\r\n +{"type":"event","length":41,"content_type":"application/json","filename":"application.log"} +{"message":"hello world","level":"error"} +'@) + $gzip.Write($bytes, 0, $bytes.Length) + $gzip.Close() + $body = $ms.ToArray() + $ms.Close() + Invoke-WebRequest -Uri "$url/api/0/envelope" -Method Post -Body $body -Headers @{ "Content-Encoding" = "gzip" } + } + + Should -ActualValue $result.HasErrors() -BeFalse + $result.Envelopes().Length | Should -Be 1 + $result.Envelopes()[0].Length | Should -Be 357 + } } From d5da121c7cf0d965fe1b76a3ad81a4d98a082d7d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 30 May 2025 19:34:50 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2427892..e1b606d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Fixed gzip-compressed HTTP requests ([#88](https://github.com/getsentry/github-workflows/pull/88)) + ## 2.12.0 ### Fixes