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

In a pull request, the method contentService.streamFile(Repository, String, String, TypeAwareOutputSupplier) throws NoSuchPathException if the file was moved in the destination branch

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • Medium
    • None
    • 2.12.1, 3.8.0
    • API - Java

    Description

      Given a simple repository

      repo
      a/Validator.java

      Precondition
      Branches master and feature/f1. feature/f1 branches from master. File Validator.java was modified in branch feature/f1 (23f27c), and in branch master moved from a/Validator.java to a/a2/a3/Validator.java (4128b7). A pull request was successful created from feature/f1 to master.

      Error 1
      In pull request TAB "Diff" the file is shown with destination path a/a2/a3. Is this the right behaviour? But file diffs are correct shown.

      But after button "View the full source of this file"

      is pressed, the warning "The path "a/a2/a3/Validator.java" does not exist at revision "refs/heads/feature/f1"" is printed.

      With debug and trace enabled, we can see the git commands:

      git for-each-ref --sort=-objecttype --format=%(objecttype)%02%(refname)%02%(objectname)%02%(*objectname) refs/heads/ refs/tags/
      git cat-file -t refs/heads/feature/f1:a/a2/a3/Validator.java
      

      In the 2nd command, the a/a2/a3/Validator.java doesn't match to branch feature/f1.

      Error 2
      Using a merge hook (MergeRequestCheck implementation), the methode contentService.streamFile() has the same problem, which leads to an Exception:

      com.atlassian.stash.exception.NoSuchPathException: The path "a/a2/a3/Validator.java" does not exist at revision "23f27cf991c70ee70da1a553cd1f9654776ba744"
      

      Where the last commit id got by

      String latestCommitId = mergeRequest.getPullRequest().getFromRef().getLatestChangeset();
      

      The resulting git command is

      git cat-file -p 23f27cf991c70ee70da1a553cd1f9654776ba744:a/a2/a3/Validator.java
      

      These both errors are present in our production stash 2.12.1 as well as in 3.8.0.
      They can be avoided by an update of the source-branch with the destination branch.
      But I think the API should handle this properly.

      Attachments

        1. image-01.png
          image-01.png
          5 kB
        2. image-02.png
          image-02.png
          3 kB
        3. image-03.png
          image-03.png
          3 kB
        4. repo.zip
          23 kB

        Issue Links

          Activity

            People

              Unassigned Unassigned
              d356a6044601 Johannes Heger (CD)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Backbone Issue Sync