Details
-
Bug
-
Resolution: Fixed
-
Low
-
4.14.5, 5.0.2
-
None
-
Severity 3 - Minor
-
4
-
Description
Summary
A 500 error is returned when accessing the Branch Permissions page of a repository under certain conditions if a branch with restrictions has been deleted.
Steps to Reproduce
- Create a branch named development/test
- Create a Branch Permission for development/test
- Delete the development/test branch
- Navigating to the Branch Permission page works as expected here and shows that the branch was deleted
- Create a branch named development
- Navigate to the Branch Permissions page of the repository
Expected Results
Branch Permission page shows the branch permission for development/test, but has the Deleted lozenge
Actual Results
A 500 error us returned and the below exception is thrown in the atlassian-bitbucket.log file:
2017-06-05 18:44:27,686 ERROR [http-nio-7990-exec-1] admin @JAGBIAx1124x13343x0 1yv5khj 10.0.2.2,192.168.5.2 "GET /rest/branch-permissions/2.0/projects/TB/repos/scratch/restrictions HTTP/1.1" c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request: "GET /rest/branch-permissions/2.0/projects/TB/repos/scratch/restrictions HTTP/1.1" com.atlassian.stash.internal.scm.git.ref.InvalidRefException: Could not read loose ref at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.retryingRead(LooseRefDb.java:156) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.internalResolve(LooseRefDb.java:240) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.lambda$internalResolve$10(LooseRefDb.java:264) at java.util.HashMap$KeySet.forEach(HashMap.java:932) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.internalResolve(LooseRefDb.java:262) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.resolve(LooseRefDb.java:123) at com.atlassian.stash.internal.scm.git.ref.CompositeGitRefDb.resolve(CompositeGitRefDb.java:109) at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.internalCall(ResolveGitRefDbCommand.java:55) at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.internalCall(ResolveGitRefDbCommand.java:23) at com.atlassian.stash.internal.scm.git.command.refdb.AbstractGitRefDbCommand.call(AbstractGitRefDbCommand.java:50) at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.call(ResolveGitRefDbCommand.java:44) at com.atlassian.stash.internal.scm.git.command.refdb.ResolveGitRefDbCommand.call(ResolveGitRefDbCommand.java:23) at com.atlassian.stash.internal.scm.git.command.TransformedGitCommand.call(TransformedGitCommand.java:45) at com.atlassian.stash.internal.repository.DefaultRefService.resolveRef(DefaultRefService.java:257) 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.repository.ref.restriction.provider.BranchMatcherProvider$1.lambda$visit$1(BranchMatcherProvider.java:55) at com.google.common.base.Suppliers$MemoizingSupplier.get(Suppliers.java:125) at com.atlassian.stash.internal.repository.ref.restriction.provider.BranchMatcher.getDisplayId(BranchMatcher.java:39) at com.atlassian.stash.internal.repository.ref.restriction.rest.RestRefMatcher.<init>(RestRefMatcher.java:28) at com.atlassian.stash.internal.repository.ref.restriction.rest.RestRefRestriction.<init>(RestRefRestriction.java:46) at com.google.common.collect.Iterators$8.transform(Iterators.java:799) at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48) at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:271) at com.google.common.collect.ImmutableList.copyOf(ImmutableList.java:226) at com.atlassian.bitbucket.rest.util.RestPage.<init>(RestPage.java:35) at com.atlassian.bitbucket.rest.util.RestPage.<init>(RestPage.java:43) at com.atlassian.bitbucket.rest.util.RestPage.<init>(RestPage.java:28) at com.atlassian.stash.internal.repository.ref.restriction.rest.AbstractRefRestrictionResource.getRestrictions(AbstractRefRestrictionResource.java:331) 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.analytics.client.filter.UniversalAnalyticsFilter.doFilter(UniversalAnalyticsFilter.java:92) at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:39) at com.atlassian.stash.internal.spring.lifecycle.LifecycleJohnsonServletFilterModuleContainerFilter.doFilter(LifecycleJohnsonServletFilterModuleContainerFilter.java:42) 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.spring.security.StashAuthenticationFilter.onSuccess(StashAuthenticationFilter.java:220) at com.atlassian.stash.internal.spring.security.StashAuthenticationFilter.doFilter(StashAuthenticationFilter.java:103) 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.user.ThreeLeggedAuthFilter.doFilter(ThreeLeggedAuthFilter.java:109) at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32) at com.atlassian.analytics.client.filter.DefaultAnalyticsFilter.doFilter(DefaultAnalyticsFilter.java:38) at com.atlassian.analytics.client.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:39) 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:86) at com.atlassian.stash.internal.hazelcast.ConfigurableWebFilter.doFilter(ConfigurableWebFilter.java:38) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.lang.Thread.run(Thread.java:745) ... 292 frames trimmed Caused by: java.nio.file.FileSystemException: /var/atlassian/application-data/bitbucket/shared/data/repositories/2/refs/heads/development/test: Not a directory at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55) at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144) at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99) at java.nio.file.Files.readAttributes(Files.java:1737) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb$FileIo.readAttributes(LooseRefDb.java:438) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.lambda$internalResolve$9(LooseRefDb.java:241) at com.atlassian.stash.internal.scm.git.ref.LooseRefDb.retryingRead(LooseRefDb.java:151) ... 61 common frames omitted
Workaround
The branch permission for the deleted branch can be deleted manually with the REST API.
- Run the following query against the DB to identify the branch permission for development/test
select * from "AO_6978BB_RESTRICTED_REF" where "REF_VALUE" = 'refs/heads/development/test';
- This query will return a row for each branch permission that's configured for the development/test branch
- For each entry, plug the REF_ID into the following DELETE REST call, run one delete for each entry
curl -u <USER> -H 'content-type: application/json' -X DELETE https:/bitbucket.company.com/rest/branch-permissions/2.0/projects/<PROJECT>/repos/<REPO>/restrictions/<REF_ID>