-
Notifications
You must be signed in to change notification settings - Fork 256
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
Facebook-style params don't work if a facet pivot is configured #3512
Comments
Thanks for reporting this. Just for more context, I've dealt with this in my local app by catching these facebook-rewritten ones and rewriting them back. Not sure that's the best solution, it's just the hack I did on noticing this. |
So i noticed my notes said I expected this PR to fix it though! And it does have a comment "Normalize facet parameters mangled by facebook" That was merged in 2020, so apparently hasn't fixed it? Or, it looks like that commit is included in Blacklight's 7.11.0 and following; are you encountering this on an earlier version of blacklight? If this hasn't fixed it, we shoudl figure out why tests didn't catch that, and make sure to fix them to! |
I see this on main and release-8.x, @jrochkind This test does not catch it because it does not have a pivot facet in the test setup. If you add the following to the And we don't appear to have any feature tests that cover this type of params. |
Cool, so the identified code above, already in BL intending to handle the Facebook-mangled URLs, is perhaps not sufficient to fix it for some uses cases -- sounds like maybe for pivot facets specifically? And needs to be improved, with test changed/added to prevent regression? Does this seem right? (I don't know much about pivot facets personally). |
Sounds right to me, @jrochkind ! |
…vot is configured each_with_object ignores the return value of the supplied block; you need to mutate the passed object instead. Prior to this change, the ramifications of bug are that: * FilterField#permitted_params always includes empty hashes (the original, unmutated object we passed to each_with_object) for a facet pivot field. * When Blacklight::Parameters::deep_merge_permitted_params comes across empty hashes, it discards a present hash in favor of the empty one. * As the permitted params for all facet fields are merged together, the presence of even one facet pivot field leads us to discard all other permitted facet field keys. * We have empty hashes, rather than hashes with permitted facet keys going into Blacklight::Parameters#deep_unmangle_params! * Blacklight::Parameters#deep_unmangle_params! can find no permitted parameters that it needs to unmangle, so the facebook params never get unmangled, causing errors and unexpected behavior elsewhere in the stack. * Facebook-style query params don't work if a facet pivot is configured.
…vot is configured each_with_object ignores the return value of the supplied block; you need to mutate the passed object instead. Prior to this change, the ramifications of bug are that: * FilterField#permitted_params always includes empty hashes (the original, unmutated object we passed to each_with_object) for a facet pivot field. * When Blacklight::Parameters::deep_merge_permitted_params comes across empty hashes, it discards a present hash in favor of the empty one. * As the permitted params for all facet fields are merged together, the presence of even one facet pivot field leads us to discard all other permitted facet field keys. * We have empty hashes, rather than hashes with permitted facet keys going into Blacklight::Parameters#deep_unmangle_params! * Blacklight::Parameters#deep_unmangle_params! can find no permitted parameters that it needs to unmangle, so the facebook params never get unmangled, causing errors and unexpected behavior elsewhere in the stack. * Facebook-style query params don't work if a facet pivot is configured. Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
…vot is configured (#3514) each_with_object ignores the return value of the supplied block; you need to mutate the passed object instead. Prior to this change, the ramifications of bug are that: * FilterField#permitted_params always includes empty hashes (the original, unmutated object we passed to each_with_object) for a facet pivot field. * When Blacklight::Parameters::deep_merge_permitted_params comes across empty hashes, it discards a present hash in favor of the empty one. * As the permitted params for all facet fields are merged together, the presence of even one facet pivot field leads us to discard all other permitted facet field keys. * We have empty hashes, rather than hashes with permitted facet keys going into Blacklight::Parameters#deep_unmangle_params! * Blacklight::Parameters#deep_unmangle_params! can find no permitted parameters that it needs to unmangle, so the facebook params never get unmangled, causing errors and unexpected behavior elsewhere in the stack. * Facebook-style query params don't work if a facet pivot is configured. Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
…vot is configured (#3514) each_with_object ignores the return value of the supplied block; you need to mutate the passed object instead. Prior to this change, the ramifications of bug are that: * FilterField#permitted_params always includes empty hashes (the original, unmutated object we passed to each_with_object) for a facet pivot field. * When Blacklight::Parameters::deep_merge_permitted_params comes across empty hashes, it discards a present hash in favor of the empty one. * As the permitted params for all facet fields are merged together, the presence of even one facet pivot field leads us to discard all other permitted facet field keys. * We have empty hashes, rather than hashes with permitted facet keys going into Blacklight::Parameters#deep_unmangle_params! * Blacklight::Parameters#deep_unmangle_params! can find no permitted parameters that it needs to unmangle, so the facebook params never get unmangled, causing errors and unexpected behavior elsewhere in the stack. * Facebook-style query params don't work if a facet pivot is configured. Co-authored-by: Christina Chortaria <christinach@users.noreply.github.com>
Background
When somebody posts a blacklight search containing a facet to Facebook, facebook rewrites the URL in an odd way:
becomes
These types of URLs have caused issues in Blacklight a few different times, see #1785, #2313, and #2654 . It's cropped up again, this time only erroring if you have a pivot facet configured.
Steps to recreate
undefined method '-' for {"0"=>"Book"}:ActiveSupport::HashWithIndifferentAccess
The text was updated successfully, but these errors were encountered: