Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-8419

Improve error reporting when creating branch with quotes in its name - the branch is still created

    XMLWordPrintable

Details

    Description

      Depending on the Git client used in Bitbucket's Server, the branch creation throws an error when using double quotes in the branch name. Although the log shows an error for having an illegal char on it, after cancelling the process and checking at the branches list, the branch is created, but without the quotes in the name.

      Git client
      This was observed on Windows, using the client git version 2.6.1.windows.1.

      Steps to Reproduce

      1. Go to your repository screen in Bitbucket Server and click on Create Branch.
      2. Set the branch name to a name containing double quotes (such as feature/Revert-"Information-Doc"-Module) and proceed creating the branch.
      3. Bitbucket throws the following error in the UI:

        The following shows up in Bitbucket's log:
        2016-02-16 18:53:37,544 ERROR [http-nio-7990-exec-1] grefosco @1N73Q8Lx1133x142x0 1omprdf 0:0:0:0:0:0:0:1 "POST /rest/branch-utils/latest/projects/PROJ/repos/bitbucket431one/branches HTTP/1.1" c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request: "POST /rest/branch-utils/latest/projects/PROJ/repos/bitbucket431one/branches HTTP/1.1"
        java.nio.file.InvalidPathException: Illegal char <"> at index 92: C:\Atlassian\ApplicationData\Bitbucket\shared\data\repositories\1\refs\heads\feature\Revert-"Information-Doc"-Module
        	at sun.nio.fs.WindowsPathParser.normalize(Unknown Source) ~[na:1.8.0_65]
        	at sun.nio.fs.WindowsPathParser.parse(Unknown Source) ~[na:1.8.0_65]
        	at sun.nio.fs.WindowsPathParser.parse(Unknown Source) ~[na:1.8.0_65]
        	at sun.nio.fs.WindowsPath.parse(Unknown Source) ~[na:1.8.0_65]
        	at sun.nio.fs.WindowsFileSystem.getPath(Unknown Source) ~[na:1.8.0_65]
        	at java.io.File.toPath(Unknown Source) ~[na:1.8.0_65]
        	at com.atlassian.stash.internal.scm.git.RawGitAgent.execute(RawGitAgent.java:239) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.RawGitAgent.execute(RawGitAgent.java:235) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.RawGitAgent.resolveBranch(RawGitAgent.java:352) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.RawGitAgent.resolveBranch(RawGitAgent.java:199) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.RawGitAgent.resolveBranch(RawGitAgent.java:189) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.command.branch.CreateBranchOutputHandler.getOutput(CreateBranchOutputHandler.java:28) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.command.branch.CreateBranchOutputHandler.getOutput(CreateBranchOutputHandler.java:14) ~[na:na]
        	at com.atlassian.stash.internal.scm.git.command.GenericGitCommand.getResult(GenericGitCommand.java:27) ~[na:na]
        	at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.internalGet(BaseCommand.java:254) ~[bitbucket-spi-4.3.1.jar:na]
        	at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.get(BaseCommand.java:221) ~[bitbucket-spi-4.3.1.jar:na]
        	at com.atlassian.bitbucket.scm.BaseCommand.call(BaseCommand.java:75) ~[bitbucket-spi-4.3.1.jar:na]
        	at com.atlassian.stash.internal.repository.DefaultRefService.createBranch(DefaultRefService.java:99) ~[bitbucket-service-impl-4.3.1.jar:na]
        	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:30) ~[atlassian-plugins-core-4.0.4.jar:na]
        	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56) ~[na:na]
        	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60) ~[na:na]
        	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70) ~[na:na]
        	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) ~[na:na]
        	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) ~[na:na]
        	at com.atlassian.bitbucket.internal.branch.DefaultBranchService.createBranch(DefaultBranchService.java:75) ~[bitbucket-branch-4.3.1.jar:na]
        	at com.atlassian.bitbucket.internal.branch.rest.BranchUtilsResource.createBranch(BranchUtilsResource.java:77) ~[bitbucket-branch-4.3.1.jar:na]
        	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
        	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
        	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
        	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
        	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
        	at com.atlassian.plugin.connect.plugin.auth.scope.ApiScopingFilter.doFilter(ApiScopingFilter.java:89) [atlassian-connect-plugin-1.1.65-bitbucket-03.jar:na]
        	at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:88) [StashAuthenticationFilter.class:na]
        	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:109) [BeforeLoginPluginAuthenticationFilter.class:na]
        	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75) [BeforeLoginPluginAuthenticationFilter.class:na]
        	at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94) [atlassian-trusted-apps-core-4.2.0.jar:na]
        	at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67) [atlassian-oauth-service-provider-plugin-2.0.3_1453269910000.jar:na]
        	at com.atlassian.core.filters.ServletContextThreadLocalFilter.doFilter(ServletContextThreadLocalFilter.java:21) [atlassian-core-4.6.19.jar:na]
        	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31) [atlassian-core-4.6.19.jar:na]
        	at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:122) [atlassian-connect-plugin-1.1.65-bitbucket-03.jar:na]
        	at com.atlassian.plugin.connect.plugin.auth.oauth.OAuth2LOFilter.doFilter(OAuth2LOFilter.java:82) [atlassian-connect-plugin-1.1.65-bitbucket-03.jar:na]
        	at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32) [jwt-plugin-1.5.5_1453269910000.jar:na]
        	at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:36) [analytics-client-4.3.9_1453269910000.jar:na]
        	at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32) [analytics-client-4.3.9_1453269910000.jar:na]
        	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:87) [BeforeLoginPluginAuthenticationFilter.class:na]
        	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73) [BeforeLoginPluginAuthenticationFilter.class:na]
        	at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:85) ~[bitbucket-service-impl-4.3.1.jar:na]
        	at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38) ~[ConfigurableWebFilter.class:na]
        	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:1.8.0_65]
        	at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_65]
        	... 291 frames trimmed
        
      4. Click in Cancel and goes to the repository's branches list. The branch is created, named as feature/Revert-Information-Doc-Module.

      Further testing
      I also tried escaping the double quote char. This seems to trigger a Git constraint, thus it fails to create the branch as well, throwing the following error in the UI:

      And showing the following in the logs:

      2016-02-16 19:49:38,450 ERROR [http-nio-7990-exec-8] grefosco @1N73Q8Lx1189x267x0 1kzoamh 0:0:0:0:0:0:0:1 "POST /rest/branch-utils/latest/projects/PROJ/repos/bitbucket431one/branches HTTP/1.1" c.a.b.i.branch.DefaultBranchService Failed to create branch feature/Revert-\"Information-Doc\"-Module in repository PROJ/bitbucket431one[1]
      com.atlassian.bitbucket.scm.CommandFailedException: 'C:\Program Files\Git\cmd\git.exe branch --no-track feature/Revert-\"Information-Doc\"-Module refs/heads/master' exited with code 128 saying: fatal: cannot lock ref 'refs/heads/feature/Revert-"Information-Doc"-Module': Unable to create 'C:/Atlassian/ApplicationData/Bitbucket/shared/data/repositories/1/refs/heads/feature/Revert-"Information-Doc"-Module.lock': Invalid argument
      	at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onError(DefaultCommandExitHandler.java:46) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler.evaluateThrowable(GitCommandExitHandler.java:106) ~[bitbucket-git-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler.onError(GitCommandExitHandler.java:160) ~[bitbucket-git-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onExit(DefaultCommandExitHandler.java:31) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.BaseCommand.callExitHandler(BaseCommand.java:138) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.internalGet(BaseCommand.java:252) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.get(BaseCommand.java:221) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.bitbucket.scm.BaseCommand.call(BaseCommand.java:75) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.stash.internal.repository.DefaultRefService.createBranch(DefaultRefService.java:99) ~[bitbucket-service-impl-4.3.1.jar:na]
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:30) ~[atlassian-plugins-core-4.0.4.jar:na]
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56) ~[na:na]
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60) ~[na:na]
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70) ~[na:na]
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) ~[na:na]
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) ~[na:na]
      	at com.atlassian.bitbucket.internal.branch.DefaultBranchService.createBranch(DefaultBranchService.java:75) ~[bitbucket-branch-4.3.1.jar:na]
      	at com.atlassian.bitbucket.internal.branch.rest.BranchUtilsResource.createBranch(BranchUtilsResource.java:77) [bitbucket-branch-4.3.1.jar:na]
      	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
      	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
      	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
      	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
      	at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:26) [applinks-plugin-5.0.5_1453269910000.jar:na]
      	at com.atlassian.plugin.connect.plugin.auth.scope.ApiScopingFilter.doFilter(ApiScopingFilter.java:89) [atlassian-connect-plugin-1.1.65-bitbucket-03.jar:na]
      	at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:88) [StashAuthenticationFilter.class:na]
      	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:109) [BeforeLoginPluginAuthenticationFilter.class:na]
      	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75) [BeforeLoginPluginAuthenticationFilter.class:na]
      	at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94) [atlassian-trusted-apps-core-4.2.0.jar:na]
      	at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67) [atlassian-oauth-service-provider-plugin-2.0.3_1453269910000.jar:na]
      	at com.atlassian.core.filters.ServletContextThreadLocalFilter.doFilter(ServletContextThreadLocalFilter.java:21) [atlassian-core-4.6.19.jar:na]
      	at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31) [atlassian-core-4.6.19.jar:na]
      	at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:122) [atlassian-connect-plugin-1.1.65-bitbucket-03.jar:na]
      	at com.atlassian.plugin.connect.plugin.auth.oauth.OAuth2LOFilter.doFilter(OAuth2LOFilter.java:82) [atlassian-connect-plugin-1.1.65-bitbucket-03.jar:na]
      	at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32) [jwt-plugin-1.5.5_1453269910000.jar:na]
      	at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:36) [analytics-client-4.3.9_1453269910000.jar:na]
      	at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:32) [analytics-client-4.3.9_1453269910000.jar:na]
      	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:87) [BeforeLoginPluginAuthenticationFilter.class:na]
      	at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73) [BeforeLoginPluginAuthenticationFilter.class:na]
      	at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:85) ~[bitbucket-service-impl-4.3.1.jar:na]
      	at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38) ~[ConfigurableWebFilter.class:na]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:1.8.0_65]
      	at java.lang.Thread.run(Unknown Source) ~[na:1.8.0_65]
      	... 287 frames trimmed
      Caused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 128
      	at com.atlassian.bitbucket.scm.SummarizingProcessHandler.complete(SummarizingProcessHandler.java:47) ~[bitbucket-spi-4.3.1.jar:na]
      	at com.atlassian.utils.process.ExternalProcessImpl.wrapUpProcess(ExternalProcessImpl.java:678) ~[atlassian-processutils-1.7.5.jar:na]
      	at com.atlassian.utils.process.ExternalProcessImpl.finish(ExternalProcessImpl.java:161) ~[atlassian-processutils-1.7.5.jar:na]
      	at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.get(BaseCommand.java:219) ~[bitbucket-spi-4.3.1.jar:na]
      	... 35 common frames omitted
      

      The branch isn't created in this case

      Attachments

        1. branch-creation1.png
          branch-creation1.png
          40 kB
        2. branch-creation2.png
          branch-creation2.png
          53 kB

        Issue Links

          Activity

            People

              khughes@atlassian.com Kristy
              grefosco Gustavo Refosco (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: