Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-12510

Calling the last-modified endpoint results in a 500 when the path is a file

    XMLWordPrintable

Details

    Description

      Issue Summary

      The last-modified REST API endpoint returns a 500 when the requested path is a file.

      Steps to Reproduce

      Make a request to the last-modified endpoint at a file: https://stash.dev.internal.atlassian.com/rest/api/1.0/projects/STASH/repos/stash/last-modified/.gitignore?at=refs/heads/master

      Expected Results

      Returns a 400, due to the endpoint being intended for directories, not files.

      Actual Results

      Response is a 500

      {"errors":[{"context":null,"message":"'/usr/bin/git ls-tree refs/heads/hi:hi --' exited with code 128 saying: fatal: not a tree object","exceptionName":"com.atlassian.bitbucket.scm.CommandFailedException"}]}

      Errors in the logs (at debug level):

      2020-08-05 08:26:00,531 DEBUG [http-nio-7990-exec-2] admin @86P5G4x506x204x0 1q47ipz 0:0:0:0:0:0:0:1 "GET /rest/api/latest/projects/PROJECT_1/repos/rep_1/last-modified/add_file/add_file.txt HTTP/1.1" c.s.j.s.container.ContainerResponse Mapped exception to response: 500 (Internal Server Error)2020-08-05 08:26:00,531 DEBUG [http-nio-7990-exec-2] admin @86P5G4x506x204x0 1q47ipz 0:0:0:0:0:0:0:1 "GET /rest/api/latest/projects/PROJECT_1/repos/rep_1/last-modified/add_file/add_file.txt HTTP/1.1" c.s.j.s.container.ContainerResponse Mapped exception to response: 500 (Internal Server Error)com.atlassian.bitbucket.scm.CommandFailedException: '/usr/local/bin/git ls-tree refs/heads/master:add_file/add_file.txt --' exited with code 128 saying: fatal: not a tree object at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onError(DefaultCommandExitHandler.java:47) at com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler.evaluateThrowable(GitCommandExitHandler.java:111) at com.atlassian.bitbucket.scm.git.command.GitCommandExitHandler.onError(GitCommandExitHandler.java:208) at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onExit(DefaultCommandExitHandler.java:32) at com.atlassian.bitbucket.internal.process.nu.NioNuProcessHandler.callExitHandler(NioNuProcessHandler.java:285) at com.atlassian.bitbucket.internal.process.nu.NioNuProcessHandler.finish(NioNuProcessHandler.java:326) at com.atlassian.bitbucket.internal.process.nu.NioNuProcessHandler.onExit(NioNuProcessHandler.java:123) at com.zaxxer.nuprocess.internal.BasePosixProcess.onExit(BasePosixProcess.java:319) at com.zaxxer.nuprocess.osx.ProcessKqueue.processEvent(ProcessKqueue.java:339) at com.zaxxer.nuprocess.osx.ProcessKqueue.process(ProcessKqueue.java:238) at com.zaxxer.nuprocess.internal.BaseEventProcessor.run(BaseEventProcessor.java:81) at com.zaxxer.nuprocess.osx.OsxProcess.run(OsxProcess.java:123) at com.zaxxer.nuprocess.osx.OsxProcessFactory.runProcess(OsxProcessFactory.java:43) at com.zaxxer.nuprocess.NuProcessBuilder.run(NuProcessBuilder.java:273) at com.atlassian.bitbucket.internal.process.nu.NuNioProcessHelper.run(NuNioProcessHelper.java:75) at com.atlassian.bitbucket.internal.process.NioCommand.call(NioCommand.java:52) at com.atlassian.stash.internal.scm.git.command.SimpleGitCommand.configureAndCall(SimpleGitCommand.java:84) at com.atlassian.stash.internal.scm.git.command.LastModifiedCommand.listFiles(LastModifiedCommand.java:155) at com.atlassian.stash.internal.scm.git.command.LastModifiedCommand.stream(LastModifiedCommand.java:240) at com.atlassian.stash.internal.scm.git.command.LastModifiedCommand.call(LastModifiedCommand.java:87) at com.atlassian.stash.internal.scm.git.command.LastModifiedCommand.call(LastModifiedCommand.java:53) at com.atlassian.stash.internal.commit.DefaultCommitService.streamLastModified(DefaultCommitService.java:363) at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26) at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56) at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60) at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70) at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) at com.atlassian.stash.internal.rest.commit.LastModifiedResource$1.write(LastModifiedResource.java:104) at com.atlassian.bitbucket.rest.util.JsonStreamingOutput.write(JsonStreamingOutput.java:23) at com.atlassian.stash.internal.rest.filter.StreamingResponseFilter$ExceptionMappingStreamingOutput.lambda$write$0(StreamingResponseFilter.java:80) at com.atlassian.stash.internal.rest.filter.StreamingResponseFilter$AbstractStreamingExceptionMapper.stream(StreamingResponseFilter.java:50) at com.atlassian.stash.internal.rest.filter.StreamingResponseFilter$ExceptionMappingStreamingOutput.write(StreamingResponseFilter.java:80) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.applinks.core.rest.context.ContextFilter.doFilter(ContextFilter.java:24) at com.atlassian.bitbucket.internal.xcode.web.XcodeUserAgentFilter.doFilter(XcodeUserAgentFilter.java:36) at com.atlassian.analytics.client.filter.UniversalAnalyticsFilter.doFilter(UniversalAnalyticsFilter.java:75) at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:48) at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59) at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42) at com.atlassian.bitbucket.internal.ratelimit.servlet.filter.RateLimitFilter.doFilter(RateLimitFilter.java:75) at com.atlassian.plugin.connect.plugin.auth.scope.ApiScopingFilter.doFilter(ApiScopingFilter.java:81) at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42) at com.atlassian.stash.internal.web.auth.AuthorizationFailureInterceptor.doFilterInternal(AuthorizationFailureInterceptor.java:39) at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:85) at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doInsideSpringSecurityChain(BeforeLoginPluginAuthenticationFilter.java:112) at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:75) at com.atlassian.security.auth.trustedapps.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:94) at com.atlassian.oauth.serviceprovider.internal.servlet.OAuthFilter.doFilter(OAuthFilter.java:67) at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42) at com.atlassian.plugin.connect.plugin.auth.oauth2.DefaultSalAuthenticationFilter.doFilter(DefaultSalAuthenticationFilter.java:69) at com.atlassian.plugin.connect.plugin.auth.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109) at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:37) at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:26) at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:48) at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42) at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doBeforeBeforeLoginFilters(BeforeLoginPluginAuthenticationFilter.java:90) at com.atlassian.stash.internal.web.auth.BeforeLoginPluginAuthenticationFilter.doFilter(BeforeLoginPluginAuthenticationFilter.java:73) at com.atlassian.stash.internal.request.DefaultRequestManager.doAsRequest(DefaultRequestManager.java:84) at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.lang.Thread.run(Thread.java:748) ... 300 frames trimmedCaused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 128 at com.atlassian.bitbucket.internal.process.nu.NioNuProcessHandler.callExitHandler(NioNuProcessHandler.java:277) ... 61 common frames omitted 

      Workaround

      Currently there is no known workaround for this behavior. A workaround will be added here when available

      Attachments

        Issue Links

          Activity

            People

              khughes@atlassian.com Kristy
              khughes@atlassian.com Kristy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Backbone Issue Sync