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

Branch name length validation doesn't count branch prefix

      Since BSERV-8631 where branch name length was increased to 100 characters the validation doesn't count branch prefix (e.g. 'feature')

        1. image-2017-12-19-12-18-36-564.png
          image-2017-12-19-12-18-36-564.png
          51 kB
        2. screenshot-1.png
          screenshot-1.png
          28 kB
        3. screenshot-2.png
          screenshot-2.png
          55 kB

            [BSERV-10287] Branch name length validation doesn't count branch prefix

            Apologies for the late update. The change to ignore the ref prefix when applying the length limit was included in the 5.16.1 patch release (and subsequent 5.16 patch releases, of course), and the 6.0.0 major release.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - Apologies for the late update. The change to ignore the ref prefix when applying the length limit was included in the 5.16.1 patch release (and subsequent 5.16 patch releases, of course), and the 6.0.0 major release. Best regards, Bryan Turner Atlassian Bitbucket

            Stefan,

            There will never be a 5.17 release. The next release will be 6.0.0. However, there will be future 5.16.x point releases, which will make this fix available without requiring a major version upgrade.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - Stefan, There will never be a 5.17 release. The next release will be 6.0.0. However, there will be future 5.16.x point releases, which will make this fix available without requiring a major version upgrade. Best regards, Bryan Turner Atlassian Bitbucket

            Stefan F. added a comment -

            @bturner: Will this be part of next release 5.17.0?
            When will be the release date?

            Stefan F. added a comment - @bturner: Will this be part of next release 5.17.0? When will be the release date?

            Stefan F. added a comment -

            Yes, better solution! Thanks for fast reaction.

            Stefan F. added a comment - Yes, better solution! Thanks for fast reaction.

            Bryan Turner (Inactive) added a comment - - edited

            stefan.felkel

            Thanks for the suggestion! I've decided to go a different way, though. Forcing end users to be aware of the extra /refs/heads/ and refs/tags/ qualifiers when creating refs produces a confusing user experience no matter how we try to message it. Rather than push that knowledge all the way through, the system now (effectively) ignores the Git qualifiers when enforcing the length limit. The branch model prefix, if any, is still considered, and the combination of both things can't exceed 100 characters, but if the branch name + refs/heads/ is over 100 characters it's no longer an error.

            The change is up for review internally, now. Once it's merged, I'm targeting the next 5.16 point release for the fix.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - - edited stefan.felkel Thanks for the suggestion! I've decided to go a different way, though. Forcing end users to be aware of the extra /refs/heads/ and refs/tags/ qualifiers when creating refs produces a confusing user experience no matter how we try to message it. Rather than push that knowledge all the way through, the system now (effectively) ignores the Git qualifiers when enforcing the length limit. The branch model prefix, if any, is still considered, and the combination of both things can't exceed 100 characters, but if the branch name + refs/heads/ is over 100 characters it's no longer an error. The change is up for review internally, now. Once it's merged, I'm targeting the next 5.16 point release for the fix. Best regards, Bryan Turner Atlassian Bitbucket

            Stefan F. added a comment - - edited

            Suggestion for the fix (please review):

            (Source Bitbucket 5.16.0)  BranchCreationData.java (105)

            FROM
             

            [...]
            int maxBranchLength = ISSUE_BRANCH_NAME_LIMIT - prefixLength;
            [...]
            

            TO
             

            [...]
            prefixLength += 1;    // if "/" is not already part of prefixLength
            int maxBranchLength = ISSUE_BRANCH_NAME_LIMIT - prefixLength - "refs/heads/".length();
            [...]
            

             

            Debugged code by an example:

            ISSUE_BRANCH_NAME_LIMIT = 100
            
            Summary = "BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds"   (84)
            Prefix = "bugfix" (6)
            
            Prefix + "/" + Summary = "bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds" (91)
            
            gitPrefix = "refs/heads" (10)
            
            gitPrefix + "/" Prefix + "/" + Summary = "refs/heads/bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds" (102)
            

            Error message produced here:

            (Source Bitbucket 5.16.0)  DefaultGitRefCommandFactory.java (225)

            if (qualifiedRefName.length() > MAX_FQ_REF_LENGTH) {
                throw new InvalidRefNameException(i18nService.createKeyedMessage("bitbucket.git.ref.qualified.name.too.long",
                        MAX_FQ_REF_LENGTH),
                        refName);
            }
            
            MAX_FQ_REF_LENGTH = 100
            
            refName = bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds
            
            qualifiedRefName = refs/heads/bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds
            

             

             

            Stefan F. added a comment - - edited Suggestion for the fix (please review): (Source Bitbucket 5.16.0)  BranchCreationData.java (105) FROM   [...] int maxBranchLength = ISSUE_BRANCH_NAME_LIMIT - prefixLength; [...] TO   [...] prefixLength += 1; // if "/" is not already part of prefixLength int maxBranchLength = ISSUE_BRANCH_NAME_LIMIT - prefixLength - "refs/heads/" .length(); [...]   Debugged code by an example: ISSUE_BRANCH_NAME_LIMIT = 100 Summary = "BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds" (84) Prefix = "bugfix" (6) Prefix + "/" + Summary = "bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds" (91) gitPrefix = "refs/heads" (10) gitPrefix + "/" Prefix + "/" + Summary = "refs/heads/bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds" (102) Error message produced here: (Source Bitbucket 5.16.0)  DefaultGitRefCommandFactory.java (225) if (qualifiedRefName.length() > MAX_FQ_REF_LENGTH) { throw new InvalidRefNameException(i18nService.createKeyedMessage( "bitbucket.git.ref.qualified.name.too. long " , MAX_FQ_REF_LENGTH), refName); } MAX_FQ_REF_LENGTH = 100 refName = bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds qualifiedRefName = refs/heads/bugfix/BIB-3781-_bib1837_-hunkchoice-stringkoord-throws-exception-if-lwert-is-out-of-bounds    

            Stefan F. added a comment - - edited

            Still happening in 5.16.0.

            It seems like I can't attach the screenshot to this image (@lbain).

            Stefan F. added a comment - - edited Still happening in 5.16.0. It seems like I can't attach the screenshot to this image (@lbain).

            I see that in Bitbucket version 5.9.1 this issue is not fixed.

            Aidas Dragunas added a comment - I see that in Bitbucket version 5.9.1 this issue is not fixed.

            Navinfo added a comment -

            We experienced this in Bitbucket version 5.13. It would be great if we could configure this restriction somehow.

            Navinfo added a comment - We experienced this in Bitbucket version 5.13. It would be great if we could configure this restriction somehow.

            Lucy added a comment -

            Hello all,

            I'm very sorry for my bad fix. I've since pushed a corrected one that will go out in the listed versions (5.9.1, 5.6.6, 5.7.4, 5.8.3) whenever they are next shipped. This will count the "/refs/heads" properly so should resolve the issue as described.

            Sorry,
            Lucy

            Lucy added a comment - Hello all, I'm very sorry for my bad fix. I've since pushed a corrected one that will go out in the listed versions (5.9.1, 5.6.6, 5.7.4, 5.8.3) whenever they are next shipped. This will count the "/refs/heads" properly so should resolve the issue as described. Sorry, Lucy

              bturner Bryan Turner (Inactive)
              3f893aeaf4b0 Jan Padera
              Affected customers:
              1 This affects my team
              Watchers:
              13 Start watching this issue

                Created:
                Updated:
                Resolved: