-
-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array serialization truncation too aggressive #315
Comments
Yes, frustrating! |
I'm closing this out as we expand arrays in PHP. |
This issue still exists. Will it be fixed? |
Just ton confirm, where are these arrays not getting expanded? (which section of the event) |
We should anyway limit the depth or let it be configurable, to avoid sending data too "deep". |
I'm trying to recall why we went this direction in the first place. I think there were certain things where we didn't want the full data repr, but honestly dont recall where. |
In my case, this additional data are required to make possible fix my issue, once that the problem is inside of this truncated array. |
According to support this feature is intended to help keep error messages within the 100kb payload limit. Maybe it would be possible to only flatten when the limit is hit, or make it opt-out? Those who are migrating from another solution (like us) are probably already having their error messages somewhat in check. |
In the 1.8.1 release that just got out, we added setters for the serializers. You can replace them with the logic you prefer. |
Hi @Jean85 can you give details about this method? In my case the data truncated from |
I'm referencing this piece of code: sentry-php/lib/Raven/Client.php Lines 1457 to 1471 in e1001f8
Those 2 serializers are the classes responsible for the compression of those arrays. You can extend them and change the behavior for the desired stuff. But using the extra field like that is a feasible solution too! |
Thanks @Jean85 I end up by ovewritting sanitize method to do the job. Here is an example in case it can help anyone: class MyRavenClient extends \Raven_Client
{
/**
* @param array $data
*/
public function sanitize(&$data)
{
// Serializes the session items as a json string
foreach ($data['user']['data'] as $k => $v) {
if (is_array($v)) {
foreach ($v as $kk => $vv) {
$data['user']['data'][$k][$kk] = json_encode($vv, JSON_PRETTY_PRINT, 3);
}
}
}
// use parent sanitizer
parent::sanitize($data);
}
} Be aware that serializer will limit the size of a string, and in this case it might be useful to provide an other serializer that has a greater limit on string size. |
Any movement on this? It would be great if serialization depth was configurable for each of the types of data this client attaches to Sentry events (user, extra, tags...). |
Did you check out the new 2.0 release? The serializer has that option and it's completely replaceable if you want. Also, for 1.x there's #632 which just needs to be released. |
@Jean85 that's great news, thank you. Will definitely be trying that out. |
This should be resolved in both 1.x and 2.x (but please use 2.x where possible). Or well, the "culprit" is now configurable so if you run into this often it's possible to modify the settings for this behaviour. 1.x: #632 |
* Improve class_alias robustness * Improve class_alias robustness * ignore unavoidable PHPStan errors
All arrays are currently being truncated to "Array of length N":
sentry-php/lib/Raven/ReprSerializer.php
Line 35 in c8bc22e
... and yet dictionaries are fully expanded. We are getting feedback from users with error data containing small arrays (e.g. 1-5 items) that are frustrated that they cannot see inside.
The text was updated successfully, but these errors were encountered: