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

ArgumentError in call_webservices.rb: Incorrect argument passing to http_post method causes failure #834

Open
pavelsky75 opened this issue Oct 16, 2024 · 0 comments

Comments

@pavelsky75
Copy link

post_failed, post_message = send(use_method, post_receive_url.url, { data: { payload: payload } })

Hello,

I've encountered an ArgumentError when using the redmine_git_hosting plugin, specifically related to the http_post method invocation in call_webservices.rb.

Error Message:

ArgumentError (wrong number of arguments (given 2, expected 1)):
plugins/redmine_git_hosting/app/services/redmine_hooks/http_helper.rb:9:in `http_post'

Problem Details:

In the file call_webservices.rb, the method http_post is called with two positional arguments:

post_failed, post_message = send(use_method, post_receive_url.url, { data: { payload: payload } })
However, the http_post method in http_helper.rb is defined to accept one positional argument and keyword arguments:

def http_post(url, **opts)
  RedmineGitHosting::Utils::Http.http_post url, **opts
end

Passing the data hash as a second positional argument leads to an ArgumentError in Ruby 2.7 and newer versions, due to changes in how keyword arguments are handled.

Cause:

Method Definition:
    http_post expects one positional argument (url) and any number of keyword arguments (**opts).
Method Invocation:
    The method is invoked with two positional arguments, the second being a hash intended as keyword arguments.

Proposed Solution:

Modify the method call in call_webservices.rb to pass the data hash as keyword arguments:

post_failed, post_message = send(use_method, post_receive_url.url, data: { payload: payload })
This change aligns with the method definition and resolves the ArgumentError.

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

1 participant