You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FormData not logged with RequestData integration #10238
When a fetcher is submitted with form data or a Form is submitted with POST, it should log FormData in Sentry. I went through the source code of RequestData integration, I even debugged it and found out that the request body in @sentry/utilsrequestdata.js -> extractRequestData does not exist.
Actual Result
Cannot find any mention of request data. Sometimes the only thing it shows is something like request_body_size
Hi @jansedlon thanks for writing in! After discussing this in our team, I think we have two issues here which we should both tackle individually:
our RequestData integration picks up the request from event.sdkProcessingMetadata. We suspect that the Remix SDK might not set this field correctly. We should verify if this is the problem, i.e. if the data is even available to the integration. Unless I'm completely missing something, the form data should be available in req.body which we already extract.
request body data should not be attached by default, given the high likelihood of it containing PII. We should gate adding the field behind the sendDefaultPII SDK option.
cc @onurtemizkan - when you have time, please take a look. ideally we resolve both (in separate PRs).
Hi @Lms24 thank you very much for your response. The request data should be available, but the body property in event.sdkProcessingMetadata.req is undefined or doesn't exist at all.
Yes, it seems body / formData is not always available when using an Express server in Remix. Which looks like the expected behaviour (See: remix-run/remix#3616)
@Lms24 - We can manually extract formData by cloning the request in action and consuming it. Then we can attach it to the scope in action. Which is not the most performance-efficient way but it's possible.
Instead of using setSDKProcessingMetadata, we can attach it to the action span, similarly how it's done in @sentry/nextjs
Hi @onurtemizkan ! Thank you for the follow up. It seems you're right. I have no idea what kind of slowdown we're talking about. Of course if you're uploading a file, then the slowdown is noticeable.
Activity
Lms24 commentedon Jan 19, 2024
Hi @jansedlon thanks for writing in! After discussing this in our team, I think we have two issues here which we should both tackle individually:
RequestDataintegration picks up the request fromevent.sdkProcessingMetadata. We suspect that the Remix SDK might not set this field correctly. We should verify if this is the problem, i.e. if the data is even available to the integration. Unless I'm completely missing something, the form data should be available inreq.bodywhich we already extract.sendDefaultPIISDK option.cc @onurtemizkan - when you have time, please take a look. ideally we resolve both (in separate PRs).
jansedlon commentedon Jan 19, 2024
Hi @Lms24 thank you very much for your response. The request data should be available, but the
bodyproperty inevent.sdkProcessingMetadata.reqis undefined or doesn't exist at all.onurtemizkan commentedon Jan 22, 2024
Thanks for reporting this @jansedlon.
Yes, it seems
body/formDatais not always available when using an Express server in Remix. Which looks like the expected behaviour (See: remix-run/remix#3616)@Lms24 - We can manually extract
formDataby cloning the request inactionand consuming it. Then we can attach it to the scope inaction. Which is not the most performance-efficient way but it's possible.Instead of using
setSDKProcessingMetadata, we can attach it to theactionspan, similarly how it's done in@sentry/nextjssentry-javascript/packages/nextjs/src/common/withServerActionInstrumentation.ts
Lines 110 to 117 in 5f0b506
What do you think? Should I go forward with that workaround?
jansedlon commentedon Jan 22, 2024
Hi @onurtemizkan ! Thank you for the follow up. It seems you're right. I have no idea what kind of slowdown we're talking about. Of course if you're uploading a file, then the slowdown is noticeable.
Lms24 commentedon Jan 23, 2024
If I understand the linked issue correctly (also worth noting, I have very limited context on using remix with express):
body-parserdoesn't work because remix can't consume it again)body-parsermiddleware work with our express request handler middleware?If I'm totally off here, I'd appreciate an explanation, thanks 😅
All in all the workaround to clone the request sounds reasonable to me if
sendDefaultPii)feat(remix): Set `formData` as `action` span data. (#10836)