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

wrong number of arguments (given 2, expected 1) #2159

Closed
gogainda opened this issue Nov 15, 2020 · 3 comments
Closed

wrong number of arguments (given 2, expected 1) #2159

gogainda opened this issue Nov 15, 2020 · 3 comments
Milestone

Comments

@gogainda
Copy link
Contributor

gogainda commented Nov 15, 2020

latest grape gem fails in multiple places with the same error :

Failures:

  1) Grape::Middleware::Auth::Strategies Digest MD5 Auth authenticates if given valid creds
     �[31mFailure/Error: builder.to_app�[0m
     �[31m�[0m
     �[31mArgumentError:�[0m
     �[31m  wrong number of arguments (given 2, expected 1)�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-2.2.3/lib/rack/head.rb:7:in `initialize'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-2.2.3/lib/rack/builder.rb:158:in `new'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-2.2.3/lib/rack/builder.rb:158:in `block in use'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-2.2.3/lib/rack/builder.rb:235:in `[]'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-2.2.3/lib/rack/builder.rb:235:in `block in to_app'�[0m
     �[36m# <internal:core> core/enumerable.rb:465:in `inject'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-2.2.3/lib/rack/builder.rb:235:in `to_app'�[0m
     �[36m# ./lib/grape/endpoint.rb:323:in `build_stack'�[0m
     �[36m# ./lib/grape/endpoint.rb:355:in `block in lazy_initialize!'�[0m
     �[36m# ./lib/grape/endpoint.rb:351:in `synchronize'�[0m
     �[36m# ./lib/grape/endpoint.rb:351:in `lazy_initialize!'�[0m
     �[36m# ./lib/grape/endpoint.rb:224:in `call'�[0m
     �[36m# ./lib/grape/router/route.rb:58:in `exec'�[0m
     �[36m# ./lib/grape/router.rb:116:in `process_route'�[0m
     �[36m# ./lib/grape/router.rb:72:in `block in identity'�[0m
     �[36m# ./lib/grape/router.rb:91:in `transaction'�[0m
     �[36m# ./lib/grape/router.rb:70:in `identity'�[0m
     �[36m# ./lib/grape/router.rb:55:in `block in call'�[0m
     �[36m# ./lib/grape/router.rb:132:in `with_optimization'�[0m
     �[36m# ./lib/grape/router.rb:54:in `call'�[0m
     �[36m# ./lib/grape/api/instance.rb:167:in `call'�[0m
     �[36m# ./lib/grape/api/instance.rb:71:in `call!'�[0m
     �[36m# ./lib/grape/api/instance.rb:66:in `call'�[0m
     �[36m# ./lib/grape/api.rb:68:in `call'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-test-1.1.0/lib/rack/mock_session.rb:29:in `request'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-test-1.1.0/lib/rack/test.rb:266:in `process_request'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-test-1.1.0/lib/rack/test.rb:129:in `custom_request'�[0m
     �[36m# /home/travis/.rvm/gems/truffleruby-head/gems/rack-test-1.1.0/lib/rack/test.rb:58:in `get'�[0m
     �[36m# /home/travis/.rvm/rubies/truffleruby-head/lib/mri/forwardable.rb:235:in `get'�[0m
     �[36m# ./spec/grape/middleware/auth/strategies_spec.rb:72:in `block (3 levels) in <top (required)>'�[0m

full logs could be found here

@eregon
Copy link
Member

eregon commented Nov 16, 2020

@gogainda Thanks for the report.
I'm not sure what you use to copy-paste, but it seems to introduce extra blank lines which is rather noisy. Could you try to fix for new bug reports?

This seems to likely be an extra empty Hash passed to initialize, so probably we need the 2.7 semantics of **hash passing nothing to fix this + handling ruby2_keywords.
https://github.com/rack/rack/blob/2.2.3/lib/rack/head.rb#L7
https://github.com/rack/rack/blob/2.2.3/lib/rack/builder.rb#L158-L160
https://github.com/rack/rack/blob/2.2.3/lib/rack/builder.rb#L235
https://github.com/ruby-grape/grape/blob/42489c243c78761238093c40f5af2b2bb9a05580/lib/grape/endpoint.rb#L286-L323

@eregon
Copy link
Member

eregon commented Nov 16, 2020

I'd guess this code causes this: https://github.com/ruby-grape/grape/blob/42489c243c78761238093c40f5af2b2bb9a05580/lib/grape/middleware/stack.rb#L35-L45
It uses *args, **opts-delegation, which is not correct in some cases on 2.7.
It should use ruby2_keywords instead.

@eregon
Copy link
Member

eregon commented Nov 20, 2020

Failures fixed by ruby-grape/grape#2132 upstream.

For the remaining keyword arguments changes for 2.7, they are tracked in #2004.

@eregon eregon closed this as completed Nov 20, 2020
@eregon eregon added this to the 21.0.0 milestone Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants