Skip to content

Invalid URL parsing on logging on ConfigServerConfigurationProvider.cs:570 #1566

@pitermarx

Description

@pitermarx

Describe the bug

In ConfigServer Configuration, if I have a comma separated list of Env/Profiles I get an exception from new Uri()

Steps to reproduce

Assuming I have this configuration

{
  "Spring": {
    "Application":{
      "Name": "sample"
    },
    "Cloud": {
      "Config": {
        "Uri": "http://localhost:8888",
        "Env": "local,staging"
      }
    }
  }
}

ConfigServerConfigurationProvider.cs:570 will throw due to an exception on UriExtensions.ToMaskedString
Even though config server itself allows multiple profiles, the string.split(',') doesn't really make sense

https://github.com/SteeltoeOSS/Steeltoe/blob/main/src/Configuration/src/ConfigServer/ConfigServerConfigurationProvider.cs#L570

https://github.com/SteeltoeOSS/Steeltoe/blob/main/src/Common/src/Common/Extensions/UriExtensions.cs#L20

public static string ToMaskedString(this Uri source)
    {
        ArgumentNullException.ThrowIfNull(source);

        string uris = source.ToString();

        if (uris.Contains(','))
        {
            return string.Join(',',
                uris.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).Select(uri => ToMaskedUri(new Uri(uri)).ToString()));
        }

        return ToMaskedUri(source).ToString();
    }

Expected behavior

I expect that the result from config server is returned, and that logging the request does not make the configuration load fail.

Environment (please complete the following information):

  • Steeltoe Version 4.0.0-rc1
  • Platform: ANY
  • OS: ANY
  • .NET Version net8.9

Additional context or links

https://github.com/SteeltoeOSS/Steeltoe/blob/main/src/Configuration/src/ConfigServer/ConfigServerConfigurationProvider.cs#L570

https://github.com/SteeltoeOSS/Steeltoe/blob/main/src/Common/src/Common/Extensions/UriExtensions.cs#L20

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component/ConfigurationIssues related to Configuration providersReleaseLine/4.xIdentified as a feature/fix for the 4.x release lineType/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions