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

2.3.0 fails to create GitHub PRs #250

Open
bastelfreak opened this issue Mar 8, 2022 · 4 comments
Open

2.3.0 fails to create GitHub PRs #250

bastelfreak opened this issue Mar 8, 2022 · 4 comments
Labels

Comments

@bastelfreak
Copy link
Member

Hi,
I installed the latest 2.3.0 release and tried to create a new PR:

$ bundle exec msync update --message "modulesync 5.2.0" --pr --pr-labels modulesync --pr-title "modulesync 5.2.0" --filter grafana
Syncing 'puppet-grafana'
bundler: failed to load command: msync (/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync)
/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://github.com/repos/voxpupuli/puppet-grafana/pulls?base=master&head=voxpupuli%3Amodulesync&state=open: 404 - Not Found (Octokit::NotFound)
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/middleware.rb:19:in `block in call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/response.rb:61:in `on_complete'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/middleware.rb:18:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-retry-1.0.3/lib/faraday/retry/middleware.rb:140:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:154:in `build_response'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/connection.rb:516:in `run_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/connection.rb:200:in `get'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/connection.rb:156:in `request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/connection.rb:84:in `paginate'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.22.0/lib/octokit/client/pull_requests.rb:20:in `pull_requests'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/git_service/github.rb:31:in `_open_pull_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/git_service/base.rb:11:in `open_pull_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/source_code.rb:64:in `open_pull_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:146:in `manage_module'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:171:in `block in update'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:170:in `each'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync.rb:170:in `update'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/cli.rb:149:in `update'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/lib/modulesync/cli/thor.rb:21:in `start'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.3.0/bin/msync:24:in `<top (required)>'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `load'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `<top (required)>'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:58:in `load'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli/exec.rb:23:in `run'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli.rb:477:in `exec'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli.rb:31:in `dispatch'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/cli.rb:25:in `start'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/exe/bundle:49:in `block in <top (required)>'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/lib/bundler/friendly_errors.rb:128:in `with_friendly_errors'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.26/exe/bundle:37:in `<top (required)>'
	from /usr/bin/bundle:23:in `load'
	from /usr/bin/bundle:23:in `<main>'

I guess /repos/ in the url is bogus?

@bastelfreak bastelfreak added the bug label Mar 8, 2022
@ekohl
Copy link
Member

ekohl commented Mar 8, 2022

No, that looks correct but only if it's using api.github.com as the domain. https://api.github.com/repos/voxpupuli/puppet-grafana/pulls?base=master&head=voxpupuli%3Amodulesync&state=open does work for me. But we don't configure the domain at all so I wonder if this is something in your settings.

@ekohl
Copy link
Member

ekohl commented Mar 8, 2022

Oh, of course just after I post that I see this:
Edit: here's the code where it is configured:

Octokit.configure do |c|
c.api_endpoint = endpoint
end
@api = Octokit::Client.new(:access_token => token)

This determines it:

# This method attempts to find git service's endpoint based on sourcecode and type
# It process in this order
# 1. use module specific configuration (ie. `base_url`)
# 2. use environment variable dependending on type (e.g. GITLAB_BASE_URL)
# 3. guess using the git remote url
# 4. fail
def self.endpoint_for(sourcecode:, type:)
endpoint = sourcecode.options.dig(type, :base_url)
endpoint ||= case type
when :github
ENV['GITHUB_BASE_URL']
when :gitlab
ENV['GITLAB_BASE_URL']
end
endpoint ||= GitService::Factory.klass(type: type).guess_endpoint_from(remote: sourcecode.repository_remote)
raise NotImplementedError, <<~MESSAGE if endpoint.nil?
Unable to guess endpoint for remote: '#{sourcecode.repository_remote}'
Please provide `base_url` option in configuration file
MESSAGE
endpoint
end

The guess method is this:

# This method attempts to guess the git service endpoint based on remote
def self.guess_endpoint_from(remote:)
hostname = extract_hostname(remote)
return nil if hostname.nil?
"https://#{hostname}"
end

So that should be overridden in github.rb so rewrite github.com to api.github.com.

The short term workaround is to set GITHUB_BASE_URL=https://api.github.com as an env var now.

simu added a commit to projectsyn/modulesync-control that referenced this issue Mar 21, 2022
This should fix the modulesync errors that are popping up for recent
runs, e.g. https://github.com/projectsyn/modulesync-control/runs/5630431030?check_suite_focus=true

See the modulesync issue at voxpupuli/modulesync#250
@bastelfreak
Copy link
Member Author

my understanding is that endpoint = sourcecode.options.dig(type, :base_url) checks our modulesync.yml for a base_url setting. We don't have that:
https://github.com/voxpupuli/modulesync_config/blob/f14a18d2ae681a4c973b3e898ab16e384046ca45/modulesync.yml#L1-L6

If I add:
base_url: "https://api.github.com/"

msync still fails:

$ bundle exec msync update --message "modulesync 5.3.0" --pr --pr-labels modulesync --pr-title "modulesync 5.3.0" --filter yum
Syncing 'puppet-yum'
bundler: failed to load command: msync (/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync)
/home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://github.com/repos/voxpupuli/puppet-yum/pulls?base=master&head=voxpupuli%3Amodulesync&state=open: 404 - Not Found (Octokit::NotFound)
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/middleware.rb:19:in `block in call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/response.rb:61:in `on_complete'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/middleware.rb:18:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/middleware/follow_redirects.rb:61:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-retry-1.0.3/lib/faraday/retry/middleware.rb:140:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/rack_builder.rb:154:in `build_response'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/connection.rb:516:in `run_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/faraday-1.10.2/lib/faraday/connection.rb:202:in `get'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/sawyer-0.9.2/lib/sawyer/agent.rb:99:in `call'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/connection.rb:156:in `request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/connection.rb:84:in `paginate'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/octokit-4.25.1/lib/octokit/client/pull_requests.rb:20:in `pull_requests'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/git_service/github.rb:31:in `_open_pull_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/git_service/base.rb:11:in `open_pull_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/source_code.rb:64:in `open_pull_request'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:146:in `manage_module'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:171:in `block in update'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:170:in `each'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync.rb:170:in `update'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/cli.rb:149:in `update'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/lib/modulesync/cli/thor.rb:21:in `start'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/gems/modulesync-2.4.0/bin/msync:24:in `<top (required)>'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `load'
	from /home/bastelfreak/code/modulesync_config/.vendor/ruby/3.0.0/bin/msync:25:in `<top (required)>'
	from /usr/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in `load'
	from /usr/lib/ruby/3.0.0/bundler/cli/exec.rb:58:in `kernel_load'
	from /usr/lib/ruby/3.0.0/bundler/cli/exec.rb:23:in `run'
	from /usr/lib/ruby/3.0.0/bundler/cli.rb:486:in `exec'
	from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /usr/lib/ruby/3.0.0/bundler/cli.rb:31:in `dispatch'
	from /usr/lib/ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /usr/lib/ruby/3.0.0/bundler/cli.rb:25:in `start'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/exe/bundle:48:in `block in <top (required)>'
	from /usr/lib/ruby/3.0.0/bundler/friendly_errors.rb:120:in `with_friendly_errors'
	from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.22/exe/bundle:36:in `<top (required)>'
	from /usr/bin/bundle:25:in `load'
	from /usr/bin/bundle:25:in `<main>'

but with export GITHUB_BASE_URL="https://api.github.com" it passes 🤔

@rwaffen
Copy link
Member

rwaffen commented Jul 5, 2024

just FYI: still problematic with 3.3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants