Error popup when trying to list quality gates

Must-share information (formatted with Markdown):

  • SonarQube Server * Enterprise Edition v10.7 (96327)
  • deployed with Docker
  • list the Quality Gates in the admin UI*

I was creating a new quality gate, and I encountered a error when creating a rule, and ended up with two copies of a rule. After I deleted the duplicate, I was unable to view the list of quality gates (see screen shot).

The rule that gave me the initial error was New Code, Security Rating is worse than “A”.
When I tried to save the rule, there was an error popup, something like, “no error returned”. I tried this a couple times, in rapid succession, and got a few popups, a mix of errors and success. The result was two copies of the same rule.
I deleted one of them, and thereafter I was unable to view quality gates, as shown in the screen shot.

The web log has the following errors (full log attached):

2025.03.04 08:47:16 ERROR web[ce1e02a0-09c0-4c0c-9acc-bde2a4b01482][o.s.s.w.WebServiceEngine] Fail to process request http://sonarqube.xello.tech/api/qualitygates/show?name=Xello%20Way%20-%20Front%20End%20with%20Coverage
java.lang.IllegalStateException: Duplicate key AYM8fCgd6MBeCehZ8uI- (attempted merging values org.sonar.db.qualitygate.QualityGateConditionDto@12fe24d0 and org.sonar.db.qualitygate.QualityGateConditionDto@630f841a)
at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)
at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182)

2025.03.04 09:07:23 ERROR web[96646276-f8e9-4d94-93e5-9809f005c8b7][o.s.s.w.WebServiceEngine] Fail to process request http://sonarqube.xello.tech/api/qualitygates/list
java.lang.IllegalStateException: Duplicate key AYM8fCgd6MBeCehZ8uI- (attempted merging values org.sonar.db.qualitygate.QualityGateConditionDto@19a3acc5 and org.sonar.db.qualitygate.QualityGateConditionDto@566121ec)
at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:135)
at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182)

sonarqube_web.log (1.1 MB)

Hey @Paul_Harapiak!

Yikes! Not sure how that managed to happen, but I can confirm the underlying database table (`quality_gate_conditions) doesn’t actually prevent duplicate values at the DB level (like having a unique index).

I wasn’t able to get that to happen via the UI, but by manually inserting a duplicate value I arrived at the same error you have.

You can check to see how many values are affected by running a command like this (this was tested against a Postgres database)

SELECT metric_uuid, qgate_uuid, COUNT(*) AS duplicate_count
FROM quality_gate_conditions
GROUP BY metric_uuid, qgate_uuid
HAVING COUNT(*) > 1;

And you should be able to remove the duplicates with a command like:

WITH duplicates AS (
    SELECT uuid, 
           ROW_NUMBER() OVER (PARTITION BY metric_uuid, qgate_uuid ORDER BY created_at) AS rn
    FROM quality_gate_conditions
)
DELETE FROM quality_gate_conditions
WHERE uuid IN (
    SELECT uuid FROM duplicates WHERE rn > 1
);

(I suggest testing this on a copy of the database, rather than production. Make sure you take a backup first)

Also, you should know that your version is past EOL. You should upgrade to either the latest version or the current LTA (long-term active version) at your earliest convenience. Your upgrade path is:

10.7 → 2025.1

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Thanks for you help; that database cleanup query worked for us.
Should I log a bug ticket for this, or would you rather do that?

I’d say that the problem started when I clicked the “save condition” button twice, and with no uniqueness guards in the database, we got the duplicates.

1 Like

Hey again!

I didn’t look before, but now that I have, I see we have an existing bug ticket for this. SONAR-20263.

I’ll link this thread to that ticket.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.