CIRCLE_BRANCH truncated for long branch names

We’ve just spent a whole lot of time debugging a bizarre issue, we have a branch name that’s 97 characters long and our git commands were behaving very strangely. We subsequently discovered that the CIRCLE_BRANCH environment variable had been truncated, even though its length is considerably shorter than the 255 max for a git branch name.

It seems to me that we should be able to 100% rely on CIRCLE_BRANCH (and the rest of the built-in env vars) to be accurate, and I wasn’t able to find anything referenced in the documentation. Is this a bug? I hope it’s a bug.

It would be best to raise a direct support issue for that rather than depending on someone from the right team seeing your post.

What VCS platform are you on?
Just for fun, I created a branch name that was ~ 110 characters (my username and a slash plus a random string: 6Z7NhOlu3rQdxKiI3EjfovcJO6Uw76jKzctSHX41lX2N0M1pMIobs7kEKyFh9FQTQYKpjG0t3m990vkZDumf6Z7ZZB67jiXEwpG2).

I added a line to a job to do a

run: echo $CIRCLE_BRANCH

and it echoed out the whole string. I don’t have any special knowledge of the limitations about this (I don’t see any documented on the page with information about the builtin env vars), but maybe you can include some more details about the exact branch name and which command(s) you’re running into issues with?