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

Hook scripts may not be invoked for cross-repository pull request merges

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Low Low
    • 6.8.1, 6.9.0
    • 6.2.0, 6.8.0
    • Repository - Hooks
    • None

      Issue Summary

      When a pull request between two repositories is merged, if the user who merges the pull request does not have at least read access to the source repository (they're only required to have access to the target repository to merge), hook scripts will not be invoked.

      Steps to Reproduce

      1. Create a hook script, using an app like External Hooks
      2. Create a repository and give 2 users access
      3. Create a personal fork of the repository as one of the two users, and do not give the other user access to it
      4. Open a pull request from the fork to the canonical repository
      5. Merge the pull request as the user without access to the fork

      Expected Results

      Hook scripts are invoked.

      Actual Results

      Hook scripts are not invoked, and the following error appears in the logs:

      2019-11-06 10:40:54,196 WARN  [AtlassianEvent::thread-3] jdoe @CHSM40x640x337x0 1ks2x81 1.1.1.1 "POST /rest/api/latest/projects/key/repos/slug/pull-requests/1/merge HTTP/1.1" c.a.s.i.h.r.DefaultRepositoryHookService [KEY/slug[1]] Error calling ScriptRepositoryHook.postUpdate
      com.atlassian.bitbucket.AuthorisationException: You are not permitted to access this resource
              at com.atlassian.stash.internal.aop.ExceptionRewriteAdvice.afterThrowing(ExceptionRewriteAdvice.java:37)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at com.atlassian.stash.internal.hook.script.DefaultHookScriptEnvironmentProvider.cloneUrls(DefaultHookScriptEnvironmentProvider.java:161)
              at com.atlassian.stash.internal.hook.script.DefaultHookScriptEnvironmentProvider.repoDetails(DefaultHookScriptEnvironmentProvider.java:198)
              at com.atlassian.stash.internal.hook.script.DefaultHookScriptEnvironmentProvider.mergeVariables(DefaultHookScriptEnvironmentProvider.java:173)
              at com.atlassian.stash.internal.hook.script.DefaultHookScriptEnvironmentProvider.create(DefaultHookScriptEnvironmentProvider.java:120)
              at com.atlassian.stash.internal.hook.script.DefaultHookScriptInvoker.lambda$prepareEnvironment$1(DefaultHookScriptInvoker.java:286)
      

      Workaround

      Ensure the user merging cross-repository pull requests has at least read access to the source repository.

            [BSERV-12045] Hook scripts may not be invoked for cross-repository pull request merges

            tcenl,

            Yes, it is. The issue wasn't marked "Closed", so it wasn't included in the release notes. Now that the release is available I've closed the issue and it's now visible on the release notes.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - tcenl , Yes, it is. The issue wasn't marked "Closed", so it wasn't included in the release notes. Now that the release is available I've closed the issue and it's now visible on the release notes. Best regards, Bryan Turner Atlassian Bitbucket

            tcenl added a comment -

            Is this bug fixed in the latest 6.8.1 release? I cannot find it in the release notes while the fix versions say it will be fixed in 6.8.1.

            tcenl added a comment - Is this bug fixed in the latest 6.8.1 release? I cannot find it in the release notes while the fix versions say it will be fixed in 6.8.1.

            This issue was originally reported for the External Hooks app: https://github.com/reconquest/atlassian-external-hooks/issues/101

            Bryan Turner (Inactive) added a comment - This issue was originally reported for the External Hooks app: https://github.com/reconquest/atlassian-external-hooks/issues/101

              bturner Bryan Turner (Inactive)
              bturner Bryan Turner (Inactive)
              Affected customers:
              1 This affects my team
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: