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

Bitbucket PR decorator fails with "key" cannot be more than 50 characters long #897

Open
SMUnlimited opened this issue Apr 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@SMUnlimited
Copy link

SMUnlimited commented Apr 8, 2024

Describe the bug
Following error occurs after sonar scan on a PR linking to bitbucket. No annotation on the bitbucket PR. Note the scan itself works fine, just the annotation fails with error below. Other repo's and branch PR's seem to work fine.

2024.04.08 14:25:14 ERROR ce[AY6-GUmO7zhALQbf94mo][o.s.c.t.p.a.p.PostProjectAnalysisTasksExecutor] Execution of task class com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask failed
com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.BitbucketException: The field 'key' cannot be more than 50 characters long
at com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.BitbucketServerClient.validate(BitbucketServerClient.java:200)
at com.github.mc1arke.sonarqube.plugin.almclient.bitbucket.BitbucketServerClient.uploadReport(BitbucketServerClient.java:135)
at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.BitbucketPullRequestDecorator.decorateQualityGateStatus(BitbucketPullRequestDecorator.java:96)
at com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask.finished(PullRequestPostAnalysisTask.java:138)
at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.executeTask(PostProjectAnalysisTasksExecutor.java:102)
at org.sonar.ce.task.projectanalysis.api.posttask.PostProjectAnalysisTasksExecutor.finished(PostProjectAnalysisTasksExecutor.java:93)
at org.sonar.ce.task.step.ComputationStepExecutor.executeListener(ComputationStepExecutor.java:89)
at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:61)
at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:75)
at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(CeWorkerImpl.java:212)
at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.run(CeWorkerImpl.java:194)
at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(CeWorkerImpl.java:160)
at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(CeWorkerImpl.java:135)
at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:87)
at org.sonar.ce.taskprocessor.CeWorkerImpl.call(CeWorkerImpl.java:53)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:74)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

To Reproduce
Not sure what key specifically is too long, but I suspect the report key itself is over 50 characters? I guess this is not configurable in uploadReport method.

Looks like this is just ultimately the project key, which yes the project key is over this many characters as its a maven project so automatically pulls in the groupId:artifactId which can be long.

Expected behavior
PR annotation occurs, or it does not but we can configure the report key as part of the scan so it comes under this limit.

Software Versions

  • SonarQube Version: 9.9.4
  • Plugin Version: 1.14.0

Workaround
We can override the project key using sonar.projectKey property, after using the sonar UI "Project Settings -> Update Key" to change the project key to desired shorter ID.

@SMUnlimited SMUnlimited added the bug Something isn't working label Apr 8, 2024
@mc1arke
Copy link
Owner

mc1arke commented Apr 19, 2024

What length is your project key on an impacted project? Sonarqube project IDs (as sent to Bitbucket) are based on the project name plus a homegrown UUID-style identifier (this switched to an actual UUID in 10.4)

@SMUnlimited
Copy link
Author

SMUnlimited commented Apr 19, 2024

Sonar Project Key: 66

Broken down into the maven properties sonar auto creates project key from:
GroupId: 40
ArtifactId: 25

@SMUnlimited
Copy link
Author

Note sonar UI says project key is legitimately allowed to be up to 400 characters long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants