danger
danger copied to clipboard
danger pr command results in Faraday error
Report
What did you do?
- Ran
bundle exec danger pr
against my GitHub-hosted private repository.- i.e.,
DANGER_GITHUB_API_TOKEN=token danger pr https://github.com/clpsplug/foobar/pull/12345
- i.e.,
- The PR number can be arbitrary; it can even be the one that does not exist!
What did you expect to happen?
The check occurs normally; in case the PR does not exist, Danger should fail accordingly.
What happened instead?
Danger blew up with an exception within the Faraday library 💥 The PAT and the repo URL are redacted.
> DANGER_GITHUB_API_TOKEN=MYTOKEN bundle exec danger pr --dangerfile=Dangerfile PRIVATE_REPO_PR_URL
bundler: failed to load command: danger (/Users/cplug/.rbenv/versions/2.7.2/bin/danger)
Traceback (most recent call last):
45: from /Users/cplug/.rbenv/versions/2.7.6/bin/bundle:23:in `<main>'
44: from /Users/cplug/.rbenv/versions/2.7.6/bin/bundle:23:in `load'
43: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/exe/bundle:37:in `<top (required)>'
42: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
41: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/exe/bundle:49:in `block in <top (required)>'
40: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/cli.rb:24:in `start'
39: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
38: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/cli.rb:30:in `dispatch'
37: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
36: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
35: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
34: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/cli.rb:497:in `exec'
33: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/cli/exec.rb:28:in `run'
32: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/cli/exec.rb:63:in `kernel_load'
31: from /Users/cplug/.gem/ruby/2.7.0/gems/bundler-2.2.2/lib/bundler/cli/exec.rb:63:in `load'
30: from /Users/cplug/.rbenv/versions/2.7.6/bin/danger:23:in `<top (required)>'
29: from /Users/cplug/.rbenv/versions/2.7.6/bin/danger:23:in `load'
28: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/bin/danger:5:in `<top (required)>'
27: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
26: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/commands/pr.rb:60:in `run'
25: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/commands/pr.rb:60:in `new'
24: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/danger_core/environment_manager.rb:30:in `initialize'
23: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/danger_core/environment_manager.rb:30:in `new'
22: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/ci_source/local_git_repo.rb:42:in `initialize'
21: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/ci_source/local_git_repo.rb:88:in `find_pull_request'
20: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/ci_source/support/pull_request_finder.rb:18:in `call'
19: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/ci_source/support/pull_request_finder.rb:50:in `find_pull_request'
18: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/danger-8.6.1/lib/danger/ci_source/support/pull_request_finder.rb:90:in `find_remote_pull_request'
17: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/octokit-4.25.0/lib/octokit/client/pull_requests.rb:33:in `pull_request'
16: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/octokit-4.25.0/lib/octokit/connection.rb:19:in `get'
15: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/octokit-4.25.0/lib/octokit/connection.rb:156:in `request'
14: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/sawyer-0.9.2/lib/sawyer/agent.rb:99:in `call'
13: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/connection.rb:200:in `get'
12: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/connection.rb:516:in `run_request'
11: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:154:in `build_response'
10: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:167:in `app'
9: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:174:in `to_app'
8: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:174:in `inject'
7: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:174:in `each'
6: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:175:in `block in to_app'
5: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/rack_builder.rb:57:in `build'
4: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb:21:in `new'
3: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb:21:in `new'
2: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-http-cache-2.4.0/lib/faraday/http_cache.rb:115:in `initialize'
1: from /Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-http-cache-2.4.0/lib/faraday/http_cache.rb:115:in `new'
/Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-http-cache-2.4.0/lib/faraday/http_cache/strategies/base_strategy.rb:36:in `initialize': uninitialized constant Faraday::HttpCache::Strategies::BaseStrategy::Logger (NameError)
Your Environment
- Which CI are you running on?
- N/A, this is an attempt to run danger locally using an existing PR.
- macOS 12.4 M1 chip, but running on Rosetta 2
- Ruby 2.7.6 from rbenv from Homebrew
- Are you running the latest version of Danger?
- I think so, my IDE reports
8.6.1
and I writegem "danger"
(without version spec) in my Gemfile.
- I think so, my IDE reports
- What is your Dangerfile? It is a Jekyll post checker. Actual checks require peeking into the file, so it is put into a shell script.
# We'd like to check if the post submitted are correctly annotated.
if git.modified_files.include? "_posts/**/*"
message "I see you are trying to add or modify a post. I'll check your post for common mistakes!"
failed = false
posts = git.modified_files.each { |path|
# must check if it is even the correct way to check via shell script
if ! system(".danger/check_post_parity.sh " + path)
warn "Post parity is not satisfied for %<path>! Visitors will see a warning when switching the language from the post page. Is this expected?" % {path: path}
failed = true
end
if ! system("./danger/check_excerpt.sh " + path)
warn "Post does not have an excerpt tag, i.e., \`<!--more-->\`!"
failed = true
end
}
end
Notes
- As the error occur regardless of the ID of the PR I pass to Danger, it is quite possible that the error is occurring before even attempting to fetch something from GitHub.
- Completely mangling the URL (so that it is not even a GitHub PR URL) produces different error, so Danger seems to detect that I'm trying to simulate a GitHub PR.
/Users/cplug/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/faraday-http-cache-2.4.0/lib/faraday/http_cache/strategies/base_strategy.rb:36:in `initialize': uninitialized constant Faraday::HttpCache::Strategies::BaseStrategy::Logger (NameError)
Looks like there's some issues with this dependency, probably worth looking into that 👍🏻
I have the same issue. Only thing I can add is that it is not a M1 Mac issue, as I can reproduce it on an Intel Mac as well.
As a workaround, you can use an older version of faraday-http-cache, the problem is only with 2.4.0.
gem 'faraday-http-cache', '2.3.0'
I fixed this issue here as I ran into the same issue myself:
https://github.com/sourcelevel/faraday-http-cache/pull/131
It looks like danger 9.1.0 seems to have resolved this issue; the local lib on my end has faraday-http-cache
2.4.0 and 2.4.1 and danger
9.1.0. Can somebody else confirm?
the local lib on my end has faraday-http-cache 2.4.0 and 2.4.1 and danger 9.1.0.
Same here.
Let me close this issue as it's resolved.