FYI, 5xx Error in api/projects/create When Project Exists and Has Multiple Branches

Running SonarQube Note that this does not have any great impact for us, just pointing out a possible side effect after some changes in case there might be others, of greater impact.

When sending a request to api/projects/create with name and project set to a key that already exists, the server returns a 5xx error (used to be 4xx in earlier versions). The traceback shows a failure:

Fail to process request <REDACTED>/api/projects/create
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(
        at org.apache.ibatis.binding.MapperMethod.execute(
        at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(
        at org.apache.ibatis.binding.MapperProxy.invoke(
        at com.sun.proxy.$Proxy81.selectByKeyCaseInsensitive(Unknown Source)
        at org.sonar.db.component.ComponentDao.selectByKeyCaseInsensitive(
        at org.sonar.server.component.ComponentUpdater.checkKeyAlreadyExists(
        at org.sonar.server.component.ComponentUpdater.createWithoutCommit(
        at org.sonar.server.component.ComponentUpdater.createWithoutCommit(
        at org.sonar.server.component.ComponentUpdater.create(

From our investigation, this might be connected to the changes made in [SONAR-17352] - Jira - since the existing project with the same name had two branches, two results are returned instead of one or none. This API used to return a 4xx exception instead of 5xx and this traceback.

Again, this does not impact us so no fix is needed, just wanted to point out a potential side-effect of the change (there may be others which are more disruptive).

1 Like

Thanks for reporting it. We’ll fix it in 9.8: [SONAR-17547] - Jira.