Closed trevorturk closed 13 years ago
I was looking at the bson gem in order to make this work generically. The bson_ruby.rb file has a bson_type method, but it throws an InvalidDocument exception if it can't map the ruby type to a bson type vs returning some sort of invalid type flag.
It seems like the easiest way to have this work generically for now is to run through the params and catch the InvalidDocumentException from bson_type then insert something similar to what you are using (ex. object type as string). I believe this would work for your case as well.
So, for each element in the params hash, we'd test if it can be serialized and, if not, store a note about the exception or type of object or something? That sounds good to me - I was thinking that this problem might not be limited to Tempfiles.
FWIW - I'm trying a more generic solution out over here: https://github.com/trevorturk/central_logger/tree/filter_params
I'm not sure if it's going to work, but I've been getting "BSON::InvalidStringEncoding: String not valid UTF-8" errors in Hoptoad, so this is an attempt to fix things up more generically as you mentioned.
This appears to have been fixed. Thanks!
This was an important bug fix for my apps at least.
It avoids an error that I was seeing a lot of: "Cannot serialize an object of class Tempfile into BSON (BSON::InvalidDocument)" by filtering tempfiles from params.
Again, let me know your level of interest, and/or if you'd like any help.