invalid event envelope. Error causes: unexpected end of file. If Context is null
See original GitHub issueEnvironment
How do you use Sentry? SaaS and Self Hosted.
Which SDK and version? latest.
Steps to Reproduce
Only happens with the caching feature.
run the snippet
using System;
using System.Globalization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Sentry;
using Sentry.Infrastructure;
SentrySdk.Init(o =>
{
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
o.Debug = true;
o.DiagnosticLogger = new TraceDiagnosticLogger(SentryLevel.Debug); //only used for revealing the data on the IDE.
o.CacheDirectoryPath = "D:/bob";
});
SentrySdk.ConfigureScope(scope =>
{
scope.Contexts["MyCoolContext"] = null;
scope.Contexts["MyCoolContext2"] = null;
});
SentrySdk.CaptureMessage("Hello Wôrld");
await Task.Delay(1000);
Expected Result
An event sent to Sentry.
Actual Result
Error: Sentry rejected the envelope 3e2862cff51d43b3860e4513ef522764. Status code: BadRequest. Error detail: invalid event envelope. Error causes: unexpected end of file.
Debug: Failed envelope '3e2862cff51d43b3860e4513ef522764' has payload:
{"sdk":{"name":"Sentry","version":"3.12.0-alpha.1"},"event_id":"3e2862cff51d43b3860e4513ef522764"}
{"type":"event","length":1965}
{"modules":{"System.Private.CoreLib":"5.0.0.0","Sentry.Samples.Console.Basic":"9.8.7.0","System.Runtime":"5.0.0.0","Sentry":"3.12.0.0","System.Net.Primitives":"5.0.0.0","System.IO.Compression":"5.0.0.0","System.Private.Uri":"5.0.0.0","System.Diagnostics.Process":"5.0.0.0","System.ComponentModel.Primitives":"5.0.0.0","Microsoft.Win32.Primitives":"5.0.0.0","System.Runtime.InteropServices":"5.0.0.0","System.Threading":"5.0.0.0","System.Diagnostics.TraceSource":"5.0.0.0","System.Net.Http":"5.0.0.0","System.Diagnostics.Tracing":"5.0.0.0","System.Diagnostics.DiagnosticSource":"5.0.0.0","System.Net.Security":"5.0.0.0","System.Security.Cryptography.X509Certificates":"5.0.0.0","System.Collections":"5.0.0.0","System.Collections.Concurrent":"5.0.0.0","System.Security.Cryptography.Algorithms":"5.0.0.0","System.Security.Cryptography.Primitives":"5.0.0.0","System.Memory":"5.0.0.0","System.IO.FileSystem":"5.0.0.0","System.Linq":"5.0.0.0","System.Threading.Thread":"5.0.0.0","System.Diagnostics.StackTrace":"5.0.0.0"},"event_id":"3e2862cff51d43b3860e4513ef522764","timestamp":"2021-11-19T21:00:13.8001629+00:00","logentry":{"message":"Hello W\u00F4rld"},"platform":"csharp","release":"Sentry.Samples.Console.Basic@9.8.7","level":"info","request":{},"contexts":{"app":{"type":"app","app_start_time":"2021-11-19T21:00:12.4422617+00:00"},"device":{"type":"device","timezone":"E. South America Standard Time","timezone_display_name":"(UTC-03:00) Brasilia","boot_time":"2021-11-17T17:50:47.9937672+00:00"},"runtime":{"type":"runtime","name":".NET","version":"5.0.10","raw_description":".NET 5.0.10"},"Current Culture":{"Name":"en-US","DisplayName":"English (United States)","Calendar":"GregorianCalendar"},"os":{"type":"os","raw_description":"Microsoft Windows 10.0.22000"}},"user":{},"environment":"debug","sdk":{"packages":[{"name":"nuget:Sentry","version":"3.12.0-alpha.1"}],"name":"sentry.dotnet","version":"3.12.0-alpha.1"}}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
java.net.SocketException: Unexpected end of file from ...
"Unexpected end of file" implies that the remote server accepted and closed the connection without sending a response.
Read more >Error Handling with SOAP Faults - Java Web Services [Book]
SOAP errors are handled using a specialized envelope known as a Fault Envelope. If an error occurs while the server processes a SOAP...
Read more >Solved: "Unexpected end of file after null" error while ex...
I am getting error as "Unexpected end of file after null" while execution REST test case with assertions. Steps: 1. create REST request...
Read more >Event codes
The most likely cause is a typographic error in a command. ... While syntactically correct the applied configuration is context invalid.
Read more >Troubleshooting for Browser JavaScript
If your application started to misbehave because of performing additional OPTIONS requests, it is most likely an issue with unwanted sentry-trace request ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It would appear that the null entries are removed from the context section of the payload when caching is enabled, and the length header is not updated.
We should ensure first that the length header is always correct, but also we should decide whether to either send null context info always or never. It shouldn’t vary based on caching.
Also I’ll just add that it would have been a better design to encapsulate the
ConcurrentDictionary
rather than extending from it.Contexts : IDictionary<string, object>
would have allowed us to filter out nulls when data was being added, rather than afterwards. It would have also hidden the concurrentness, which is an implementation detail. But changing it now would be a breaking change, so perhaps for the future.