hygieia / hygieia-scm-bitbucket-collector

Hygieia Collector for BitBucket
https://github.com/capitalone/Hygieia/blob/gh-pages/pages/hygieia/collectors/scm/bitbucket.md
Apache License 2.0
1 stars 22 forks source link

hygieia -bitbucket connectivity issue #7

Closed abhinay8 closed 5 years ago

abhinay8 commented 5 years ago

Can someone help me with the below error 2019-07-22 17:05:01,018 [taskScheduler-1] ERROR c.c.d.collector.SCMHttpRestClient - Cannot decrypt this message Null input buffer 2019-07-22 17:05:01,048 [taskScheduler-1] ERROR o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task. org.springframework.web.client.HttpClientErrorException: 401 null at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:493) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at com.capitalone.dashboard.collector.SCMHttpRestClient.makeRestCall(SCMHttpRestClient.java:48) ~[bitbucket-scm-collector-3.0.2-SNAPSHOT.jar!/:3.0.2-SNAPSHOT] at com.capitalone.dashboard.collector.PullRequestCollector.getPullRequests(PullRequestCollector.java:95) ~[bitbucket-scm-collector-3.0.2-SNAPSHOT.jar!/:3.0.2-SNAPSHOT] at com.capitalone.dashboard.collector.GitCollectorTask.collect(GitCollectorTask.java:182) ~[bitbucket-scm-collector-3.0.2-SNAPSHOT.jar!/:3.0.2-SNAPSHOT] at com.capitalone.dashboard.collector.CollectorTask.run(CollectorTask.java:63) ~[core-3.0.4.jar!/:3.0.2-SNAPSHOT] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0] at java.lang.Thread.run(Thread.java:744) [na:1.8.0] 2019-07-22 17:06:58,411 [pool-3-thread-1] INFO org.mongodb.driver.connection - Closed connection [connectionId{localValue:6, serverValue:50}] to localhost:27017 because it is past its maximum allowed idle time.

my property file is as below

dbname=dbuser dbhost=localhost dbport=27017 dbusername=xxxxxx dbpassword=xxxxxx git.cron=0 0/5 git.host=https://bitbucket:4297/

git.api=/api/2.0/repositories/ git.api=/rest/api/1.0/ git.commitThresholdDays=15 git.pageSize=25 git.product=server git.key=Ht8dhdmdlcodfgdbydbdmMTMOyXUzREvbpG key=Ht8dhdmdlcodfgdbydbdmMTMOyXUzREvbpG bitbucket.key=Ht8dhdmdlcodfgdbydbdmMTMOyXUzREvbpG logging.level.com.capitalone.dashboard=DEBUG logging.level.com.capitalone.dashboard.collector=DEBUG logging.level.com.atlassian.git=INFO

I am unable to get data from bitbucket at all 2019-07-22 17:00:00,113 [taskScheduler-1] ERROR c.c.d.collector.SCMHttpRestClient - Cannot decrypt this message Null input buffer 2019-07-22 17:00:00,171 [taskScheduler-1] ERROR c.c.d.c.DefaultBitbucketServerClient - Failed to obtain commits from https:URLXXXXXXXX/commits?until=refs%2Fheads%2Fmaster&limit=25 org.springframework.web.client.HttpClientErrorException: 401 null

adhish70 commented 5 years ago

Hey, I think you need to generate the token from the hygieia-core and then use it here. You collector is not able to decrypt. Try looking for how to setup private repos in hygieia.

abhinay8 commented 5 years ago

I did that and still see the same issue.

tmohamme commented 5 years ago

@abhinay8 facing the same issue, [taskScheduler-1] ERROR c.c.d.collector.SCMHttpRestClient - Cannot decrypt this message Null input buffer 2019-07-23 19:46:10,462 [taskScheduler-1] ERROR o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task. org.springframework.web.client.HttpClientErrorException: 401 null at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:493) ~[spring-web-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at com.capitalone.dashboard.collector.SCMHttpRestClient.makeRestCall(SCMHttpRestClient.java:48) ~[bitbucket-scm-collector-3.0.2-SNAPSHOT.jar!/:3.0.2-SNAPSHOT] at com.capitalone.dashboard.collector.PullRequestCollector.getPullRequests(PullRequestCollector.java:95) ~[bitbucket-scm-collector-3.0.2-SNAPSHOT.jar!/:3.0.2-SNAPSHOT] at com.capitalone.dashboard.collector.GitCollectorTask.collect(GitCollectorTask.java:182) ~[bitbucket-scm-collector-3.0.2-SNAPSHOT.jar!/:3.0.2-SNAPSHOT] at com.capitalone.dashboard.collector.CollectorTask.run(CollectorTask.java:63) ~[core-3.0.4.jar!/:3.0.2-SNAPSHOT] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.2.5.RELEASE.jar!/:4.2.5.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_212] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_212] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_212] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_212] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]

tmohamme commented 5 years ago

In the above error I see (CollectorTask.java:63) ~[core-3.0.4.jar!/:3.0.2-SNAPSHOT],

If it's referring to hygieia-core then the version of hygieia-core I have is core-3.1.3-SNAPSHOT.jar,

I am not sure if it will effect the api which is build on previous version of hygieia-core, I am confused

tmohamme commented 5 years ago

And why does Bitbucket collector has a reference to hygieia-core 3.0.4 rather than 3.1.3 ?

tmohamme commented 5 years ago

Screen Shot 2019-07-23 at 4 55 07 PM

Sbrenthughes commented 5 years ago

If you see here at com.capitalone.dashboard.collector.SCMHttpRestClient.makeRestCall the error is occurring in the SCMHttpRestClient class not the core. Have you tried passing in the username and password via the Repo widget configuration? I get the same error when not passing values from the UI. It should probably be fixed to not require credentials.

Sbrenthughes commented 5 years ago

I have created an issue specifically for the null pointer fix. https://github.com/Hygieia/Hygieia/issues/3066

tmohamme commented 5 years ago

I have configured bitbucket login credentials under general Configurations tab in settings, I am fetching data from a public repository, that is the reason, I have not included credentials for a private repo, which in the widget configuration is being asked, please correct me if I am wrong, Thanks.

Sbrenthughes commented 5 years ago

So this error only happens when you don't have credentials in either place. If you have one or the other it will work.

tmohamme commented 5 years ago

And when I am passing the url with .git extension, apiUrl builder is building it with concatenating, /projects & /repos, however it is adding time with format "%tFT%<tRZ", which is throwing a page not found error 404,

tmohamme commented 5 years ago

The other thing I would like to notify is, String queryUrl = apiUrl.concat("/commits?sha=" + repo.getBranch()

in this piece of code the &since should be &changessince, when I looked at the bitbucket api, that is what is looking for, if it is just &since it is not returning any commits, if it is &changessince then it is returning all the commits on the browser.

Sbrenthughes commented 5 years ago

Please feel free to submit a PR for those changes.

tmohamme commented 5 years ago

@Sbrenthughes how do I connect with you on gitter.im ?

tmohamme commented 5 years ago

I mean when can you be available on gitter.im ?

Sbrenthughes commented 5 years ago

I believe I have messaged you already

Sbrenthughes commented 5 years ago

Closing due to inactivity. Please reopen if you still face issues.