Skip to content

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

Open
@pavelsky75

Description

@pavelsky75

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions