“java.lang.IllegalStateException: Fail to restore Quality profile backup” when importing profile with api

72 views
Skip to first unread message

jan.v...@gmail.com

unread,
May 12, 2017, 4:02:33 PM5/12/17
to SonarQube

Hi, I’ve made a copy of the Sonar Way Java profile using the backup option in the in the quality profiles page. This results in a file I've named java-test.xml. Next, I opened the file in a text editor and changed the name to copy2, like this <name>copy2</name>.

Then I tried to import the profile using Postman with a POST to this URL: ‘localhost:9000/api/qualityprofiles/restore’ and a ‘backup’ parameter pointing to the file I previously exported. Import fails with an error message in Postman

 

{ "errors": [ {

      "msg": "An error has occurred. Please contact your administrator"

    }]}

 

and a stacktrace (java.lang.IllegalStateException: Fail to restore Quality profile backup) in SonarQube’s logs, see image:









Next I tried importing the same java-test.xml file in SonarQube’s management page, using the ‘restore profile’ option on the ‘quality profiles’ tab. This works without errors.

 

Am I using the correct api call or is something wrong in the api itself?

 

I’m using version 6.3.1 of the Docker container from https://hub.docker.com/_/sonarqube/

nicolas...@sonarsource.com

unread,
May 15, 2017, 5:29:26 AM5/15/17
to SonarQube
Hi Jan,

Since it works with SonarQube built-in capability, but fails with your Postman attempt, it looks to me that you need to double-check Postman behaviour when it comes to submitting POST requests. Especially when I read this:

Then I tried to import the profile using Postman with a POST to this URL: ‘localhost:9000/api/qualityprofiles/restore’ and a ‘backup’ parameter pointing to the file I previously exported

Is Postman actually opening the file and putting its content as body of the request ? or is it just putting the filepath as value of backup parameter ? The latter can only fail, as the server has no clue what to do with such a filepath. Have a look on that front, and generally speaking comparing server logs (including access.log) together with request format should help you diagnose the difference.

Best regards,
Nicolas

Jan Vermeir

unread,
May 15, 2017, 6:12:31 AM5/15/17
to SonarQube
Hi Nicolas, thanks! that was indeed the problem. I was assuming Postman would load the contents of the file, but it doesn't, of course.

Thanks for your help.

Jan.
Reply all
Reply to author
Forward
0 new messages