Incorrect information in payload delived by webhook

I have installed a webhook via the API and have received an event. I was unable to find a proper specification (e.g. a data schema) of the values to be expected but the payload seems to contain all of the information of the example payload at: Webhooks | SonarCloud

In addition to the properties of the example, the payload also contains a property called “branch”:

"branch": {
  "name":"20"
  "type":"PULL_REQUEST"
  "isMain":false
  "url":"https://sonarcloud.io/dashboard?id=[my project's key]&pullRequest=20"
}

Unfortunately, the branch’s name is wrong. It seems to be a stringified version of the pull request’s number but I’m not sure. In any case, there is no branch whose name is “20” in my repository, so I want to report this bug.

It would be really nice to actually get the branch’s name so I don’t need to integrate with github in order to figure out the name of the branch based on the stringified version of the PR’s number, all while hoping that this undocumented behavior of the webhook will continue.

Hi,

For the analysis this payload relates to, what was being analyzed? A branch or a PR?

 
Ann

1 Like

Ah, I didn’t know that there was a difference. Thank you very much. It was a PR analysis. I would’ve liked to get the name of the branch used in the PR.

However, I have now changed the “Long-lived branches pattern” to .* and have pushed a commit to a new branch and created a PR. I have also pushed a new branch and then pushed a new commit to it w/o creating a PR. None of these activities have resulted in me receiving an event payload about a branch analysis. I have only received an event that contains "type":"PULL_REQUEST" with the name again being the stringified version of the PR number on github. I think there still is something I’m missing. But I also think that describing the PR number as a branch name is wrong.

EDIT: I have checked https://sonarcloud.io/project/branches_list?id=[my project's key]. It still shows the “Long-lived branches pattern” to be .* but it does not show any branches other than “main”.

Hey @m1cm1c

How are you running your analysis? Is it Automatic Analysis? CI-Based Analysis (if the latter, which CI?)

Hi, @Colin,
it’s automatic analysis on github.

Thanks. In that case, you’re running into a limitation:

Currently, automatic analysis has the following limitations:

  • It is only available for GitHub repositories.
  • Branch analysis (analysis of non-pull request branches other than the main branch) is not supported.

Only the main branch and pull requests get analyzed, so it’s expected that you only see the main branch.

1 Like

Thank you very much for this information! :slight_smile: