pronto icon indicating copy to clipboard operation
pronto copied to clipboard

Issue with Bitbucket Integration

Open abhinavmsra opened this issue 7 years ago • 10 comments

I am trying to integrate with Bitbucket and Sempahore CI. But when i run

bundle exec pronto run -f bitbucket_pr -c origin/development

i keep getting following error:

bundler: failed to load command: pronto (/home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/bin/pronto)
NoMethodError: undefined method `map' for "Not Found":String
Did you mean?  tap
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/clients/bitbucket_client.rb:36:in `openstruct'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/clients/bitbucket_client.rb:20:in `pull_comments'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/bitbucket.rb:5:in `pull_comments'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/formatter/pull_request_formatter.rb:6:in `existing_comments'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/formatter/git_formatter.rb:6:in `format'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto.rb:67:in `block in run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto.rb:66:in `each'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto.rb:66:in `run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/cli.rb:61:in `block in run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/cli.rb:60:in `chdir'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/cli.rb:60:in `run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/bin/pronto:6:in `<top (required)>'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/bin/pronto:23:in `load'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/bin/pronto:23:in `<top (required)>'

My .pronto.yml files looks like this:

all:
  exclude:
    - 'spec/**/*'
bitbucket:
  slug: [USER_ACCOUNT]/[REPO_NAME]
  username: [ACCOUNT_EMAIL]
  password: [ACCOUNT_PASSWORD]
max_warnings: 150
verbose: true
format: "[%{runner}] [%{level}] => %{msg}"

abhinavmsra avatar Aug 26 '17 00:08 abhinavmsra

@abhinavmsra I do think this is a bug, but there might be two things at play:

  1. The NoMethodError: undefined method map' for "Not Found":String` is us not doing a good job of handling BitBucket errors
  2. The "Not Found" makes me wonder if your slug/user/password combination isn't incorrect and as such they're returning 404 and we aren't handling it.

Thoughts?

doomspork avatar Aug 26 '17 04:08 doomspork

@doomspork actually just noticed, the issue is weirder.

when i ssh into the CI container and run the same command, i runs fine and posts the comments too. Its just when running the command as a build script it fails.

Not sure whats making it fail.

abhinavmsra avatar Aug 26 '17 10:08 abhinavmsra

@abhinavmsra do you have any logs from your CI?

doomspork avatar Aug 26 '17 15:08 doomspork

@doomspork

Running Pronto::Brakeman
Running Pronto::DirtyWords
Running Pronto::Flay
Running Pronto::RailsBestPractices
Running Pronto::RailsSchema
Running Pronto::Reek
Running Pronto::Rubocop
Running Pronto::Scss
bundler: failed to load command: pronto (/home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/bin/pronto)
NoMethodError: undefined method `map' for "Not Found":String
Did you mean?  tap
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/clients/bitbucket_client.rb:36:in `openstruct'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/clients/bitbucket_client.rb:20:in `pull_comments'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/bitbucket.rb:5:in `pull_comments'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/formatter/pull_request_formatter.rb:6:in `existing_comments'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/formatter/git_formatter.rb:6:in `format'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto.rb:67:in `block in run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto.rb:66:in `each'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto.rb:66:in `run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/cli.rb:61:in `block in run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/cli.rb:60:in `chdir'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/lib/pronto/cli.rb:60:in `run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/gems/pronto-0.9.5/bin/pronto:6:in `<top (required)>'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/bin/pronto:23:in `load'
  /home/runner/travelbook-web/vendor/bundle/ruby/2.3.0/bin/pronto:23:in `<top (required)>'

abhinavmsra avatar Aug 28 '17 10:08 abhinavmsra

@abhinavmsra this is the line throwing the error: https://github.com/prontolabs/pronto/blob/master/lib/pronto/clients/bitbucket_client.rb#L19

The BitBucket API is returning "Not Found" when we try to pull comments for your project. Can you double and triple check the username, password, and repo slug are correct?

You might want to confirm you can access to your repo via cURL too: https://confluence.atlassian.com/bitbucket/use-the-bitbucket-cloud-rest-apis-222724129.html

doomspork avatar Aug 28 '17 18:08 doomspork

@doomspork The credentials are correct because

  1. I can run the same command from local and it works.
  2. Also when I SSH into the Semaphore CI and run the command, it works there too.

Maybe something funky happening with the Semaphore build. I cannot say whether its a Gem issue or a build issue though. I will spend sometime on it and will share my findings.

abhinavmsra avatar Aug 29 '17 08:08 abhinavmsra

Thank you @abhinavmsra! Please do report back when you have more details, always happy to help 😀

doomspork avatar Sep 01 '17 16:09 doomspork

@abhinavmsra did you manage to get it working? 😀

mmozuras avatar Oct 15 '17 19:10 mmozuras

I'm running into a similar error on circle ci

bundler: failed to load command: pronto (/usr/local/bundle/bin/pronto)
NoMethodError: undefined method `each_pair' for ["type", "error"]:Array
Did you mean?  each_slice
  /usr/local/lib/ruby/2.5.0/ostruct.rb:94:in `initialize'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/clients/bitbucket_client.rb:47:in `new'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/clients/bitbucket_client.rb:47:in `block in openstruct'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/clients/bitbucket_client.rb:47:in `each'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/clients/bitbucket_client.rb:47:in `map'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/clients/bitbucket_client.rb:47:in `openstruct'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/clients/bitbucket_client.rb:20:in `pull_comments'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/bitbucket.rb:5:in `pull_comments'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/formatter/pull_request_formatter.rb:6:in `existing_comments'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/formatter/git_formatter.rb:6:in `format'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto.rb:67:in `block in run'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto.rb:66:in `each'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto.rb:66:in `run'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/cli.rb:66:in `block in run'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `chdir'
  /usr/local/bundle/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `run'
  /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
  /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
  /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
  /usr/local/bundle/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
  /usr/local/bundle/gems/pronto-0.10.0/bin/pronto:6:in `<top (required)>'
  /usr/local/bundle/bin/pronto:23:in `load'
  /usr/local/bundle/bin/pronto:23:in `<top (required)>'
Exited with code 1
CircleCI received exit code 1

tevariou avatar Oct 16 '19 10:10 tevariou

@tevariou any luck on this issue?

talha-diverst avatar Feb 17 '21 13:02 talha-diverst