Giter Club home page Giter Club logo

Comments (4)

bitsandfoxes avatar bitsandfoxes commented on June 12, 2024

Fair point. If the SDK can already predict that the envelope will be rejected due to size it should not simply attempt to send it.
I'm not sure where the attached file comes from? Are you capturing the exception manually?

from sentry-dotnet.

fifi98 avatar fifi98 commented on June 12, 2024

Correct - I am capturing the exception manually.

Here is a minimal reproduction snippet of code:

[HttpPost]
public async Task<IActionResult> Upload([FromForm] IFormFileCollection file)
{
    try
    {
        throw new Exception();
    }
    catch (Exception e)
    {
        SentrySdk.CaptureException(e);
    }

    return Ok();
}

from sentry-dotnet.

fobos531 avatar fobos531 commented on June 12, 2024

Correct - I am capturing the exception manually.

Here is a minimal reproduction snippet of code:

[HttpPost]
public async Task<IActionResult> Upload([FromForm] IFormFileCollection file)
{
    try
    {
        throw new Exception();
    }
    catch (Exception e)
    {
        SentrySdk.CaptureException(e);
    }

    return Ok();
}

@bitsandfoxes To add to this (I'm on the same team), we are utilizing the overload of the CaptureException method to configure the local scope on the fly and its where we are attaching the file, like so:

  // Create attachment from uploaded file
  var attachment = new Attachment(AttachmentType.Default, new StreamAttachmentContent(uploadedFileStream),
      file.FileName, file.ContentType);

  // Add attachment to Sentry
  scope.AddAttachment(attachment);

We can work around the envelope exceeded limits by attaching a custom event processor as well, which strips the file from the request body, but if we do not do this, it might be useful for the SentrySdk to be a little more specific on the why the envelope was rejected, e.g. a multipart/form-data file was detected that exceeds the permitted file size limit.

Additionally, the attachment flow I outlined above does not seem to work - even though we attached the attachment in what looks to be the correct manner, it is still not visible in Sentry on web. Any pointers?

from sentry-dotnet.

bitsandfoxes avatar bitsandfoxes commented on June 12, 2024

This starts to sound like multiple issues.
I'll bring "hitting size limits" up with the team. It seems like a recurring thing that we can definitely improve.

A workaround for this issue would be to set a method in SetBeforeSend that omits the Request.Data in case of file uploads.

You could rely on the hint object that gets passed to the SetBeforeSend callback instead of adding your own eventprocessor. The hint holds the attachments as a list and if you remove an attachment there it won't be sent with the event.

Additionally, the attachment flow I outlined above does not seem to work - even though we attached the attachment in what looks to be the correct manner, it is still not visible in Sentry on web. Any pointers?

Without having access to any logs it's a bit hard to tell. But you're right. It appears to be the correct manner. The only thing that comes to mind would be that since you're adding the attachment as a stream, during the upload that stream has been closed/disposed, causing the SDK to fail internally which would not be reported.

from sentry-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.