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

Fail to mark a permission template as default

    Details

      Description

      The permission templates created before version 6.3 can have internal keys longer than 40 characters (kind of slug of template name). As the DB column to store the default template is 40 characters long, marking these templates as default fails with error:

      2018.02.07 10:53:27 ERROR web[AWFvqiBBq5fKsNfJAAB2][o.s.s.w.WebServiceEngine] Fail to process request http://localhost:9000/api/permissions/set_default_template
      org.apache.ibatis.exceptions.PersistenceException: 
      ### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(40)
      ### The error may involve defaultParameterMap
      ### The error occurred while setting parameters
      ### SQL: update organizations     set       default_perm_template_project = ?,       default_perm_template_view = ?,       updated_at = ?     where       uuid = ?
      ### Cause: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(40)
      	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)
      	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
      	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
      	at com.sun.proxy.$Proxy29.updateDefaultTemplates(Unknown Source)
      	at org.sonar.db.organization.OrganizationDao.setDefaultTemplates(OrganizationDao.java:98)
      	at org.sonar.server.permission.ws.template.SetDefaultTemplateAction.setDefaultTemplateUuid(SetDefaultTemplateAction.java:122)
      	at org.sonar.server.permission.ws.template.SetDefaultTemplateAction.doHandle(SetDefaultTemplateAction.java:100)
      	at org.sonar.server.permission.ws.template.SetDefaultTemplateAction.handle(SetDefaultTemplateAction.java:90)
      	at org.sonar.server.ws.WebServiceEngine.execute(WebServiceEngine.java:103)
      	at org.sonar.server.ws.WebServiceFilter.doFilter(WebServiceFilter.java:86)
      	at org.sonar.server.platform.web.MasterServletFilter$GodFilterChain.doFilter(MasterServletFilter.java:126)
      	at org.sonar.server.platform.web.MasterServletFilter.doFilter(MasterServletFilter.java:95)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:87)
      	at org.sonar.server.user.UserSessionFilter.doFilter(UserSessionFilter.java:71)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.sonar.server.platform.web.SecurityServletFilter.doHttpFilter(SecurityServletFilter.java:72)
      	at org.sonar.server.platform.web.SecurityServletFilter.doFilter(SecurityServletFilter.java:48)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.sonar.server.platform.web.RedirectFilter.doFilter(RedirectFilter.java:61)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.sonar.server.platform.web.requestid.RequestIdFilter.doFilter(RequestIdFilter.java:63)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.sonar.server.platform.web.RootFilter.doFilter(RootFilter.java:62)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      	at ch.qos.logback.access.tomcat.LogbackValve.invoke(LogbackValve.java:256)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
      	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
      	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(40)
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
      	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169)
      	at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:158)
      	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
      	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
      	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
      	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
      	at org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:52)
      	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
      	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
      	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
      	... 49 common frames omitted
      

      Note that no errors are displayed in the webapp. Operation is silently ignored.

      Reproducer

      1. start SonarQube 6.7
      2. log in with account "admin"
      3. browse to Administration > Security > Permission Templates
      4. create the template named "foo"
      5. edit database: update permission_templates set kee = 'AWFvqqHWQ7JFXSpYMHDQAWFvqqHWQ7JFXSpYMHDQAWFvqqHWQ7JFXSpYMHDQAWFvqqHWQ7JFXSpYMHDQAWFvqqHWQ7JFXSpYMHDQ' where name='foo'
      6. click on button Actions > Set Default. Failure - see web.log

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                eric.hartmann Eric Hartmann
                Reporter:
                simon.brandhof Simon Brandhof
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: