'Show More' button doesn't work when issues list is filtered to 'New Code'

The ‘Show More’ button does not function properly when attempting to view issues with the ‘New Code’ filter enabled. In some projects the first page of issues will display but clicking ‘Show More’ does nothing, so it is not possible to get to subsequent pages of issues. On another project the issues page shows, ‘0 of 56 shown’ beside the ‘Show More’ button. That is a bug since at least the first X records should be visible. And clicking ‘Show More’ does nothing.

Removing the ‘New Code’ filter works in that ALL of the issues will be visible. But for our project that results in far too many issues to navigate. I only want to see the new issues.

  • I am using version 9.6
  • Steps to reproduce issue: Apply the ‘New Code’ filter to a project when viewing issues
  • Solutions I have already tried:
  1. I deleted the ES index folder so the indexes would get rebuilt. This did not work. After restarting Sonarqube the problem persists.
  2. The ‘New Code’ setting in Admin was previously set to 30 days. I modified it to the default (“since last version”) and re-ran analysis but this also didn’t fix the issue.
1 Like

Hi,

I’m not replicating this. Can you check your console for errors?

 
Ann

By ‘console’ are you referring to the log files? If so, which log file should I be looking at?

Thanks

Hi,

Sorry, I meant the browser console in the browser’s developer tools.

 
Ann

Thanks - after a moment I wonder if that is what you were referring to :wink:

I just pulled up Chrome console and found one 404 error the moment the initial page of issues is displayed. In my case the 404 is on:

http://10.168.1.106:9000/api/alm_settings/get_binding?project=com.regattacentral%3Arc-core

Clicking ‘Show More’ results in the following in the Network tab. But the page doesn’t update, refresh or show any more issues:

{“total”:329,“p”:6,“ps”:100,“paging”:{“pageIndex”:6,“pageSize”:100,“total”:329},“effortTotal”:3280,“issues”:,“components”:,“rules”:,“users”:[{“login”:“admin”,“name”:“Administrator”,“avatar”:“d456a19ebae1c6c329148cb39057d3f1”,“active”:true}],“languages”:[{“key”:“py”,“name”:“Python”},{“key”:“go”,“name”:“Go”},{“key”:“kotlin”,“name”:“Kotlin”},{“key”:“terraform”,“name”:“Terraform”},{“key”:“cloudformation”,“name”:“CloudFormation”},{“key”:“kubernetes”,“name”:“Kubernetes”},{“key”:“js”,“name”:“JavaScript”},{“key”:“ts”,“name”:“TypeScript”},{“key”:“css”,“name”:“CSS”},{“key”:“ruby”,“name”:“Ruby”},{“key”:“scala”,“name”:“Scala”},{“key”:“cs”,“name”:“C#”},{“key”:“java”,“name”:“Java”},{“key”:“web”,“name”:“HTML”},{“key”:“jsp”,“name”:“JSP”},{“key”:“flex”,“name”:“Flex”},{“key”:“xml”,“name”:“XML”},{“key”:“php”,“name”:“PHP”},{“key”:“text”,“name”:“Text”},{“key”:“vbnet”,“name”:“VB.NET”},{“key”:“yaml”,“name”:“YAML”},{“key”:“json”,“name”:“JSON”}],“facets”:}

and the response to that HTTP 200 request is:

{“total”:329,“p”:5,“ps”:100,“paging”:{“pageIndex”:5,“pageSize”:100,“total”:329},“effortTotal”:3280,“issues”:,“components”:,“rules”:,“users”:[{“login”:“admin”,“name”:“Administrator”,“avatar”:“d456a19ebae1c6c329148cb39057d3f1”,“active”:true}],“languages”:[{“key”:“py”,“name”:“Python”},{“key”:“go”,“name”:“Go”},{“key”:“kotlin”,“name”:“Kotlin”},{“key”:“terraform”,“name”:“Terraform”},{“key”:“cloudformation”,“name”:“CloudFormation”},{“key”:“kubernetes”,“name”:“Kubernetes”},{“key”:“js”,“name”:“JavaScript”},{“key”:“ts”,“name”:“TypeScript”},{“key”:“css”,“name”:“CSS”},{“key”:“ruby”,“name”:“Ruby”},{“key”:“scala”,“name”:“Scala”},{“key”:“cs”,“name”:“C#”},{“key”:“java”,“name”:“Java”},{“key”:“web”,“name”:“HTML”},{“key”:“jsp”,“name”:“JSP”},{“key”:“flex”,“name”:“Flex”},{“key”:“xml”,“name”:“XML”},{“key”:“php”,“name”:“PHP”},{“key”:“text”,“name”:“Text”},{“key”:“vbnet”,“name”:“VB.NET”},{“key”:“yaml”,“name”:“YAML”},{“key”:“json”,“name”:“JSON”}],“facets”:}

p.s. I also tried in the latest version of Firefox and reproduced the issue (so it isn’t browser related).

Interestingly, the pagination widget initially showed, “10 of 329 shown”. Clicking ‘Show More’ once didn’t do anything. Clicking it a second time caused one more issue to be appended to the list of issues. (so it then showed, “11 of 329 shown”. Clicking ‘Show More’ again doesn’t do anything regardless of how many clicks. Developer Tools in FF and Chrome shows a successful 200 but nothing in UI changes. The GET URL is

http://rc-dev2:9000/api/issues/search?componentKeys=com.regattacentral%3Arc-core&s=FILE_LINE&resolved=false&inNewCodePeriod=true&types=BUG&ps=100&p=5&additionalFields=_all&timeZone=America%2FNew_York

)

Hi,

Thanks for the additional investigation. I’m going to flag this for more expert attention.

 
Ann

Hi @SteveRC,

This is all very strange. I cannot reproduce the error either. We can indeed see from the payloads you pasted that the "issues" property is just an empty array ([ ]). Which explains why the UI doesn’t update (it doesn’t have any data to append).

Let’s see if we can figure this out.

  • Did you upgrade from a previous version of SonarQube? If so, which one?
  • Is this happening for multiple/all projects on your instance, or only one?
  • What DB are you using (Oracle, Postgres, MSSQL)? What version?

Thank you for the assistance. Here are the responses to those questions:

  1. The issue has been occurring for at least a few versions and persists through upgrades
  2. It is happening on multiple projects. I just looked at a few and it is even happening on a project which has only three issues linked to ‘New Code’ but the label beside the ‘Show More’ button says, ‘0 of 3 shown’, the button doesn’t do anything and no issues are shown
  3. I’m using Postgres 12.12 (Ubuntu 12.12-0ubuntu0.20.04.1)`

Thanks,
Steve

Hm, and I’m guessing you never have this discrepancy when you’re not filtering by New Code, correct? I.e., the “show more” button works correctly when the “New Code” filter is disabled? I suspect some data corruption, but if this only happens on New Code and not on Overall Code (which includes New Code issues), I would expect the data to be OK.

Some further questions which may help us:

  • Do the projects on which this happens have something in common? E.g., a similar set-up, which is different from other projects? A similar New Code period setting?
  • Does this happen on new projects as well, or only on older projects that have existed through multiple upgrades? And if they have all existed for some time, would you know during which version(s) of SonarQube they were created (big ask, I know)? The reason I’m asking is that it has happened once in the past that a DB upgrade from one version to another caused a bug, but this bug would only become apparent multiple upgrades later. It’s unlikely this is the case here, but you never know.

That is correct - the issue is only happening when I filter by ‘New Code’.

I’ve checked multiple projects and the issue is occurring with all of them. All of the projects have existed since we onboarded with SQ and unfortunately I don’t have any newer projects.

I know the issue has been happening for at least a year and I just kept putting up with it. So it has persisted through multiple upgrades. If I recall correctly, i migrated from the built-in DB (H2) to Postgresql a few years back. The issue definitely wasn’t occurring on H2.

My limited mental model of how this works was that it might be related to the ES search engine, which is why i had it rebuild the indexes. but obviously that didn’t help.

Thanks,
Steve

Is the number of issues correct on the project Overview’s New Code tab?

example:

Or is it incorrect as well? Does the Quality Gate ever fail correctly, for example when you have some Bugs in New Code? And if/when that happens, how do you find the information about the issues you need to correct?

If i’m understanding correctly than it looks like that is not working. New Code on Measures page shows ‘304’. But clicking it goes to the list of issues, with ‘New Code’ filter enabled but showing 1,396 issues.

image.png

OK, so there really is something weird going on, because the data on the Overview isn’t computed via Elastic Search, but comes straight from the database.

I’m running out of ideas, TBH. I’m really leaning toward some data corruption inside the database. Perhaps some constraints that are messed up.

You mentioned you might have migrated from H2. This is surprising, because not only is it not something we support, but unless you do it manually, it’s not even possible. Do you recall doing this with some custom script? Or perhaps your recollection is incorrect, and you started afresh with Postgres? Did you update Postgres at any time?

Wouter,

Thank you for the email and update. I may have confused things when mentioning H2. I’ve never done anything special with respect to the database and always just used what came with the product. My recollection is that a while back I did take advantage of a migration that came as part of a version update to migrate from the bundled database to a standalone postgres instance. the only other aspect that may be a factor is postgres getting updated to a new major version at some point.

Is there a way to rebuild the database easily?

Thanks,
Steve

On which edition are you currently? Community, Developer, Enterprise?

Community v9.6.0.59041

Thanks,
Steve

Wouter,

I ran the following posgres command. Perhaps this helps shed some light on the issue?

postgres=# \connect sonar
You are now connected to database “sonar” as user “postgres”.
sonar=# reindex database sonar;
ERROR: could not create unique index “live_measures_component”
DETAIL: Key (component_uuid, metric_uuid)=(AVrOYj0lEBN5Dhb4o4a_, 91) is duplicated.
CONTEXT: parallel worker
sonar=#

Wouter,

I think it is safe for you to close this ticket. I just deleted all the projects and re-added them to SonarQube. Assuming the duplicate key issue was the root cause this should address the problem.

Thanks,
Steve

Thanks for getting back with this info. OK, I’ll mark your previous comment as the Solution, but feel free to re-open the thread if that didn’t solve the problem.