Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse key="value" in an override such as secret when secret is containing equal sign #101

Closed
sebbrochet opened this issue Jun 15, 2022 · 2 comments

Comments

@sebbrochet
Copy link

Hello,

Code in InplaceOverride method in https://github.com/microsoft/delta-kusto/blob/main/code/DeltaKustoIntegration/Parameterization/ParameterOverrideHelper.cs is checking for the proper number of equal signs in an override but doesn't properly support the value containing an equal sign by itself and throws an error:

public static void InplaceOverride(object target, IEnumerable<string> pathOverrides)
        {
            if (pathOverrides.Any())
            {
                try
                {
                    var splits = pathOverrides.Select(t => t.Split('='));
                    var noEquals = splits.FirstOrDefault(s => s.Length != 2);

                    if (noEquals != null)
                    {
                        throw new DeltaException(
                            $"Override must be of the form path=value ; "
                            + $"exception:  '{string.Join('=', noEquals)}'");
                    }

So, let's say you want to override the secret parameter and the secret is containing an equal sign, it'll break:

Activating Client...                                                                                                                                                                    
Client Activated                                                                                                                                                                        
Newer clients available:  0.10.2.109                                                                                                                                                    
Loading parameters at 'C:\XXX\rev-engineer-parameters.yaml'                                                                                    
Error:  Issue with the following parameter override:  'System.String[]'                                                                                                                 
  Error:  Override must be of the form path=value ; exception:  'tokenProvider.login.secret=LXXXXX4='                                               
  Exception encountered:  DeltaKustoLib.DeltaException ; Override must be of the form path=value ; exception:  'tokenProvider.login.secret=LXXXXX4='
  Stack trace:     at DeltaKustoIntegration.Parameterization.ParameterOverrideHelper.InplaceOverride(Object target, IEnumerable`1 pathOverrides)

Whereas what is passed is: tokenProvider.login.secret="LXXXXX4="
Which should be considered as a valid key/value override.

@sebbrochet
Copy link
Author

sebbrochet commented Jun 17, 2022

OK, managed to work around it by building a local version of the tool with below change:

using System.Text.RegularExpressions;

...

public static void InplaceOverride(object target, IEnumerable<string> pathOverrides)
{
    if (pathOverrides.Any())
    {
        try
        {                                        
            var regExStr = @"(?<path>.+)=(?<textValue>.+)";                    
            var regEx = new Regex(regExStr, RegexOptions.Compiled); 
            var splits = pathOverrides.Select(s => regEx.Match(s)).Where(m => m.Success);
            var overrides = splits.Select(m => (path: m.Groups[1].Value, textValue: m.Groups[2].Value));
            InplaceOverride(target, overrides);                    
        }
        catch (Exception ex)
        {
            throw new DeltaException(
                $"Issue with the following parameter override:  '{pathOverrides}'",
                ex);
        }
    }
}

sebbrochet added a commit to sebbrochet/delta-kusto that referenced this issue Jun 21, 2022
@vplauzon
Copy link
Contributor

Good catch. Fixed in 0.10.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants