Open
Description
What happened?
My pipeline is named "JAzure CI". I added this script to my pipeline:
set -x
echo '$(Build.DefinitionName)'
echo "$BUILD_DEFINITIONNAME"
It is evaluated as:
##[debug]script=set -x
echo 'JAzvv73vv73vv70='
echo "$BUILD_DEFINITIONNAME"
And it prints:
+ echo JAzvv73vv73vv70=
+ echo JAzvv73vv73vv70=
JAzvv73vv73vv70=
JAzvv73vv73vv70=
It should show JAzure CI
.
I've seen the same thing happen for a job name substitution as well. In both cases, the mangled name causes the build to fail because the name is wrong.
I suspect this PR is roundtripping the string incorrectly due to UTF-8 encoding of non-UTF-8 data, causing the issue:
I don't know how/where this is applied to the variable value, but I was able to reproduce the behavior: https://dotnetfiddle.net/ppLkgJ
using System;
using System.Text;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
{
Console.WriteLine(DeactivateVsoCommandsIfBase64Encoded("Sign Archives")); // SignAu+/vSHvv73vv73vv70=
Console.WriteLine(DeactivateVsoCommandsIfBase64Encoded("JAzure CI")); // JAzvv73vv73vv70=
Console.WriteLine(DeactivateVsoCommandsIfBase64Encoded("Hello World")); // (Exception)
}
public static string DeactivateVsoCommandsIfBase64Encoded(string input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input), "Input string cannot be null.");
}
if (input.Length == 0)
{
return string.Empty;
}
byte[] decodedBytes = Convert.FromBase64String(input);
string decodedString = Encoding.UTF8.GetString(decodedBytes);
decodedString = ScrapVsoCommands(decodedString);
return Convert.ToBase64String(Encoding.UTF8.GetBytes(decodedString));
}
private static string ScrapVsoCommands(string input)
{
return Regex.Replace(input, "##vso", "**vso", RegexOptions.IgnoreCase);
}
}
Versions
Agent 4.257.0
Observed on Azure Linux 3.0 and Windows. (Not sure of exact versions.)
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
Version Dev20.M256.1 (AzureDevOps_M256_20250527.2)
Operation system
No response
Version controll system
No response