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

NoMethodError: undefined method `collect' for "()"@158:Parslet::Slice #101

Open
dkinzer opened this issue May 31, 2019 · 1 comment
Open

Comments

@dkinzer
Copy link
Member

dkinzer commented May 31, 2019

So we’re getting a failure on from blacklight_advanced_search whenever we search anything with empty parens in it like “()” as the smallest case example. Anyone else see this… We are on the latest blacklight_advanced_search gem but we suspect issue goes back to other versions….
The error is
NoMethodError: undefined method `collect' for "()"@158:Parslet::Slice
and it’s getting thrown here

[GEM_ROOT]/bundler/gems/blacklight_advanced_search-9c23f0e9aad6/lib/parsing_nesting/tree.rb:40:in `to_node_tree'
38     elsif tree.is_a? Hash
39       if list = tree[:list]
40         List.new(list.collect { |i| to_node_tree(i, query_parser) }, query_parser)
41       elsif tree.has_key?(:and_list)
42         AndList.new(tree[:and_list].collect { |i| to_node_tree(i, query_parser) }, query_parser)```
@jrochkind
Copy link
Member

jrochkind commented May 31, 2019

BAS tries to parse a boolean query, yes. This was a “feature”/requirement.

There’s no way to do that without making some ‘natural language’ things fail. There’s no way to fix this. See also recent discussion about “Portland OR bicycles”.

If you put the thing with parens in double quotes, it’ll probably work. (although the parens are probably stripped out by your Solr query parser anyway and have no effect on results).

print() will fail, but I bet "print()" will succeed.

I don’t know if there’s anything that can be done about this. I suppose there could be a feature to toggle off boolean query parsing, and just treat everything entered as a literal.

If you have boolean query parsing -- which was originally a requirement/goal/feature of this (now very old) library -- there are necessarily going to be things that don't parse.

Although I suppose it would also be better if you got an actual parse error as an exception here, instead of a kind of random uncaught exception. I'm not sure it's worth the effort to make that so, I don't think it will get you any closer to something you actually want.

bibliotechy pushed a commit to tulibraries/tul_cob that referenced this issue Sep 16, 2020
If an empty param,`()`, is included in a query, the boolen query parser included from advanced search gem throws an error.

It is documented as an issue upstream at projectblacklight/blacklight_advanced_search#101, but at the moment no fix upstream is proposed.

This PR works around the issue by removing empty parens from the query string. It does not impact parens containing content.
bibliotechy pushed a commit to bibliotechy/blacklight_advanced_search that referenced this issue Sep 23, 2020
This change allows an empty set of parens, `()`, to be in a string and to be parsed as a token. Prior to this change, and empty set of parens would be parsed as a list with no contents which could not be successfully parsed, but instead results in a error as described in projectblacklight#101.

This change fixes issue projectblacklight#101.
bibliotechy pushed a commit to bibliotechy/blacklight_advanced_search that referenced this issue Sep 23, 2020
This change allows an empty set of parens, `()`, to be in a string and to be parsed as a token. Prior to this change, and empty set of parens would be parsed as a list with no contents which could not be successfully parsed, but instead results in a error as described in projectblacklight#101.

This change fixes issue projectblacklight#101.
bibliotechy pushed a commit to bibliotechy/blacklight_advanced_search that referenced this issue Sep 24, 2020
This change allows an empty set of parens, `()`, to be in a string and to be parsed as a token. Prior to this change, and empty set of parens would be parsed as a list with no contents which could not be successfully parsed, but instead results in a error as described in projectblacklight#101.

This change fixes issue projectblacklight#101.
dkinzer pushed a commit that referenced this issue Oct 5, 2022
This change allows an empty set of parens, `()`, to be in a string and to be parsed as a token. Prior to this change, and empty set of parens would be parsed as a list with no contents which could not be successfully parsed, but instead results in a error as described in #101.

This change fixes issue #101.
dkinzer pushed a commit that referenced this issue Oct 12, 2022
This change allows an empty set of parens, `()`, to be in a string and to be parsed as a token. Prior to this change, and empty set of parens would be parsed as a list with no contents which could not be successfully parsed, but instead results in a error as described in #101.

This change fixes issue #101.
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

No branches or pull requests

2 participants