Uploaded image for project: 'SonarQube'
  1. SonarQube
  2. SONAR-10714

api/qualityprofiles/search is failing when no default profile is found for a language

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None
    • Edition:
      Community

      Description

      Use Case

      1. Install a new plugin language FOO on the server => At startup, each organization will be associated with built-in profiles from the plugin, and one built-in profile will be set as default
      2. Uninstall the plugin FOO
      3. Create some organization BAR
      4. Re-install the plugin FOO

      When displaying the list of quality profiles of the organization BAR, there'll be no default quality profile for language FOO.
      Trying to display the list of quality profiles of a project of BAR will fail with an error 500 :

      {
        "errors": [
          {
            "msg": "An error has occurred. Please contact your administrator"
          }
        ]
      }
      

      And on server's side the following stacktrace will be displayed:

      2018.05.23 09:38:35 ERROR web[AWOL7vZpK7yT7gCpAAA7][o.s.s.w.WebServiceEngine] Fail to process request http://localhost:9000/api/qualityprofiles/search?organization=test&project=test
      java.lang.NullPointerException: null
      	at org.sonar.server.qualityprofile.ws.SearchAction.lambda$byProject$5(SearchAction.java:246)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
      	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
      	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
      	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
      	at org.sonar.server.qualityprofile.ws.SearchAction.searchProfiles(SearchAction.java:219)
      	at org.sonar.server.qualityprofile.ws.SearchAction.load(SearchAction.java:159)
      	at org.sonar.server.qualityprofile.ws.SearchAction.doHandle(SearchAction.java:147)
      	at org.sonar.server.qualityprofile.ws.SearchAction.handle(SearchAction.java:133)
             ....
      

      Moreover, no more analysis could be executed from scanner side as it's using this web service to get the list of quality profiles.

      Possible solutions

      • Prevent api/qualityprofiles/search to fail when no default quality profile is found for a language
      • When synchronizing quality profiles at startup and updating each organization, sync all built-in profiles found in database (even the ones provided by uninstalled plugins)
      • Remove association of default quality profiles for each profiles of organization (if possible)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                julien.lancelot Julien Lancelot
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: