Skip to content

Conversation

@josemalm32
Copy link
Contributor

  • Create branch fix/minio-usesl-strict from main
  • Update MinioClientSettings.cs to make UseSsl parsing strict
    • Add UseSslKeys constant array for UseSsl variants (UseSsl, UseSSL, Ssl)
    • Update ParseConnectionString to handle UseSsl from connection string
    • Add TryParseBool method with strict bool parsing (only "true"/"false")
    • Remove any URI scheme-based UseSsl inference
  • Add comprehensive tests for the new strict parsing behavior
    • Test explicit UseSsl=true/false in connection string
    • Test that URI scheme doesn't affect UseSsl
    • Test strict boolean parsing (reject "1"/"0", "yes"/"no", "on"/"off")
    • Test all UseSsl key variants (UseSsl, UseSSL, Ssl)
    • Test case-insensitive parsing
  • Address code review feedback
    • Translate Spanish comment to English
    • Improve null handling in TryParseBool method

Changes made:

  • Updated ParseConnectionString to no longer infer UseSsl from https/http URI schemes
  • Added strict TryParseBool that only accepts boolean values or "true"/"false" strings
  • Added support for UseSsl key variants (UseSsl, UseSSL, Ssl)
  • Added 20+ comprehensive tests covering all edge cases
  • Addressed code review comments: translated comment and improved null handling

Copilot AI and others added 3 commits November 1, 2025 21:39
Co-authored-by: josemalm32 <23101537+josemalm32@users.noreply.github.com>
…ling

Co-authored-by: josemalm32 <23101537+josemalm32@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 1, 2025 21:56
@josemalm32
Copy link
Contributor Author

@dotnet-policy-service agree

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the MinioClientSettings connection string parsing to introduce explicit handling of the UseSsl property and prevents automatic inference of SSL usage from URI schemes. The key change is that UseSsl now defaults to false and must be explicitly set in connection strings or configuration.

Key changes:

  • Added explicit UseSsl property handling with support for multiple key variants (UseSsl, UseSSL, Ssl)
  • Introduced strict boolean parsing that only accepts "true"/"false" strings (case-insensitive), rejecting numeric and yes/no values
  • Modified connection string parsing to never infer UseSsl from URI schemes (https:// or http://)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/CommunityToolkit.Aspire.Minio.Client/MinioClientSettings.cs Refactored ParseConnectionString to handle UseSsl explicitly with strict boolean parsing; added early return for null/whitespace; added TryParseBool helper method
tests/CommunityToolkit.Aspire.Minio.Client.Tests/ConfigurationTests.cs Added comprehensive test coverage for UseSsl behavior including default value, explicit true/false, key variants, rejected formats, and non-inference from URI schemes
Comments suppressed due to low confidence (1)

src/CommunityToolkit.Aspire.Minio.Client/MinioClientSettings.cs:100

  • The method lacks XML documentation comments. All public and internal methods should have XML doc comments per project conventions. Add a summary explaining the strict parsing behavior and document the parameters and return value.
    // Strict boolean parsing: only accepts bool or the strings "true"/"false" (case-insensitive).
    private static bool TryParseBool(object? value, out bool result)

private const string ConnectionStringEndpoint = "Endpoint";
private const string AccessKey = "AccessKey";
private const string SecretKey = "SecretKey";
private static readonly string[] UseSslKeys = new[] { "UseSsl", "UseSSL", "Ssl" };
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use collection expression syntax instead of array initializer for consistency with project coding style. Change to: private static readonly string[] UseSslKeys = [\"UseSsl\", \"UseSSL\", \"Ssl\"];

Copilot generated this review using guidance from repository custom instructions.
Comment on lines 74 to 84
foreach (var key in UseSslKeys)
{
if (connectionBuilder.TryGetValue(key, out var useSslObj))
{
Credentials = new MinioCredentials
if (TryParseBool(useSslObj, out var parsed))
{
AccessKey = accessKey.ToString()!, SecretKey = secretKey.ToString()!
};
UseSsl = parsed;
break;
}
}
}
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.

Copilot uses AI. Check for mistakes.
Comment on lines 76 to 83
if (connectionBuilder.TryGetValue(key, out var useSslObj))
{
Credentials = new MinioCredentials
if (TryParseBool(useSslObj, out var parsed))
{
AccessKey = accessKey.ToString()!, SecretKey = secretKey.ToString()!
};
UseSsl = parsed;
break;
}
}
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 'if' statements can be combined.

Copilot uses AI. Check for mistakes.
Assert.Null(settings.Endpoint);

settings = new MinioClientSettings();
settings.ParseConnectionString("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: string.Empty could be more convenient here

@Harold-Morgan
Copy link
Contributor

PR itself looks good!

I'm a little bit concerned about turning off security features by default, though, is it more convenient?

@josemalm32
Copy link
Contributor Author

josemalm32 commented Nov 2, 2025

Hi @Harold-Morgan

Thanks for review 💯

If you use Minio locally, it is simpler to have SSL set to false. There is no need to configure self-signed certificates. And I suppose that if it is activated, the Hosting.MinIO package would have to be modified. The idea of adding SSL to the connection string is for production environments. In my case, I tried to connect but never succeeded because I always ended up calling port 80 (non-SSL) instead of 443 (SSL).

Thanks

private const string ConnectionStringEndpoint = "Endpoint";
private const string AccessKey = "AccessKey";
private const string SecretKey = "SecretKey";
private static readonly string[] UseSslKeys = new[] { "UseSsl", "UseSSL", "Ssl" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

// Strict boolean parsing: only accepts bool or the strings "true"/"false" (case-insensitive).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? bool.TryParse is case insensitive so do we really care? This seems like code for codes sake.

Refactor SSL key handling and remove unused boolean parsing method.
Removed multiple tests for SSL connection string parsing.
{
Credentials = new MinioCredentials
{
AccessKey = accessKey.ToString()!, SecretKey = secretKey.ToString()!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josemalm32
Copy link
Contributor Author

Adjusted with the required changes.

Thanks 💯

@Harold-Morgan
Copy link
Contributor

Harold-Morgan commented Nov 4, 2025

Some tests fail and need fixing :(

Apart from that looks great!

if (connectionBuilder.TryGetValue(UseSslKey, out var useSslObj))
{
Endpoint = serviceUri;
if (bool.TryParse(useSslObj, out var parsed))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you need to explicitly cast useSslObj to string over here

Fix compilation error and improve readability of SSL parsing.
@josemalm32
Copy link
Contributor Author

Fix compilation error and improve readability of SSL parsing.

Thanks to both of you😄

Copy link
Member

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and we're almost ready to merge

public void ParseConnectionString_HttpsUri_DoesNotInferUseSsl()
{
var settings = new MinioClientSettings();
settings.ParseConnectionString("https://minio.example.com:9000");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the ParseConnectionString method is internal you'll need to expose it to the test project with <InternalsVisibleTo Include="CommunityToolkit.Aspire.Minio.Client.Tests" />

You'll find a bunch of examples of other projects using InternalsVisibleTo in the repo

@aaronpowell
Copy link
Member

@josemalm32 can you get this actioned in the next day so it can make the release this week with aspire 13

@aaronpowell aaronpowell added this to the 13 milestone Nov 11, 2025
@josemalm32
Copy link
Contributor Author

Hi @aaronpowell Sorry for the delay. With the latest change, the tests are working fine. I've tried running it locally and it works.

Thanks 😄

@aaronpowell aaronpowell merged commit fb042c4 into CommunityToolkit:main Nov 12, 2025
108 checks passed
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

Successfully merging this pull request may close these issues.

3 participants