Skip to content
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

[#3512] Support facebook-style query params in cases where a facet pivot is configured #3514

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

sandbergja
Copy link
Contributor

@sandbergja sandbergja commented Feb 20, 2025

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 were 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.
  • As a result, Facebook-style query params didn't work if a facet pivot is configured.

Closes #3512

…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>
@sandbergja sandbergja force-pushed the pivot-facet-facebook-params branch from 3f84146 to beec8f5 Compare February 21, 2025 16:35
@sandbergja sandbergja marked this pull request as ready for review February 21, 2025 17:06
@@ -803,7 +803,7 @@ def export_as_mock
end

it "is empty for empty result sets", :integration do
get :page_links, params: { f: { "format" => 'empty-result-set' }, counter: 1 }
get :page_links, params: { f: { "format" => ['empty-result-set'] }, counter: 1 }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting the structure of the params

Copy link
Contributor

@maxkadel maxkadel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sandbergja! Looks good. I appreciate all the tests, and the debugging - looks like it was pretty tricky to figure out what was going on!

@sandbergja sandbergja merged commit 3620b34 into main Feb 24, 2025
11 checks passed
@sandbergja sandbergja deleted the pivot-facet-facebook-params branch February 24, 2025 17:58
@jrochkind
Copy link
Member

ooh this is prob a good candidate for a backport. Bad one! Thank you for finding and fixing!

sandbergja added a commit that referenced this pull request Feb 24, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Facebook-style params don't work if a facet pivot is configured
3 participants