Error 500 when trying to create project that exists already (instead of 400) After upgrade to 9.7.1

Hi,

We have some automation to provision our SQ Enterprise instance (automate creating project).

Since upgrade from Enterprise from 9.6 to 9.7.1 we got 500 errors (instead of 400) when we try to create a project with an existing key. (It only happens when project has data).

It’s not mega user friendly and raise error on SQ logs.

This is the stacktrace we have

2022.11.25 05:23:17 ERROR web[AYRlG4F28z1KNFNoBkbM][o.s.s.w.WebServiceEngine] Fail to process request http://****/api/projects/create?name=*****&project=****&visibility=private

org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 59
113891at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:80)
113892at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
113893at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
113894at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)

What’s going on here ?

Thanks!

Valentin

1 Like

Hey there.

Thanks for the report! Take a look at this thread – I’m pretty sure it’s the same issue (and will get fixed a release coming soon)

1 Like

Hi @Colin

Sadly even after upgrading to 9.9 latest LTS I have 500 error when trying to create existing projects.

2023.02.21 11:11:58 ERROR web[AYZygfWvqRRm9qF8AElH][o.s.s.w.WebServiceEngine] Fail to process request http://*******/api/projects/create?name=*******&project=P*******&visibility=private
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(DefaultSqlSession.java:80)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
at jdk.proxy2/jdk.proxy2.$Proxy89.selectByKeyCaseInsensitive(Unknown Source)
at org.sonar.db.component.ComponentDao.selectByKeyCaseInsensitive(ComponentDao.java:213)
at org.sonar.server.component.ComponentUpdater.checkKeyAlreadyExists(ComponentUpdater.java:137)
at org.sonar.server.component.ComponentUpdater.createWithoutCommit(ComponentUpdater.java:121)
at org.sonar.server.component.ComponentUpdater.create(ComponentUpdater.java:94)
at org.sonar.server.project.ws.CreateAction.doHandle(CreateAction.java:119)
at org.sonar.server.project.ws.CreateAction.handle(CreateAction.java:110)
at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:111)
at org.sonar.server.platform.web.WebServiceFilter.doFilter(WebServiceFilter.java:84)
at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:153)
at org.sonar.server.platform.web.SonarLintConnectionFilter.doFilter(SonarLintConnectionFilter.java:66)
at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:153)
at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:116)
at jdk.internal.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.security.SecurityUtil.lambda$execute$0(SecurityUtil.java:280)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)

Thanks!

Valentin

Hi @jonesbusy,

Thanks for providing the logs.

It seems to be the same issue with the one that is supposed to be fixed.
I wasn’t able to reproduce the issue on the 9.9 LTS version. I tried with multiple existing projects, with data and branches, and all of them returned 400 Bad Request responses with the appropriate error message when the key already exists.

Can you check on your side if you get the 500 response on other projects too?

Hi @dimitris.kavvathas

Thanks for your answer. No it seems to happen with only a subset of projects. Doesn’t happen in our staging environment without any analyzing data.

I’m happy to help you debug (maybe provide me a SQL query to run on our DB for the project that is causing issue).

We are using the SonarQube official helm chart (latest version) with latest LTS.

We upgraded every version from 9.6 to 9.9.

Not sure if it helps.

Thanks

Hello @jonesbusy,

Thanks for offering to help.

In order to debug, I’ll need some information from the components database table.
I have sent you a private message for more information.

Thanks!

Thanks @dimitris.kavvathas

I’ve provided necessary information on private message.

Best regards,

Hello,

With the data provided by @jonesbusy we managed to reproduce the issue.
I created a bug ticket to track its progress.

Thanks again @jonesbusy for helping us identify the problem! :smiley:

1 Like

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