Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 22, 2025

Adapt connection string generation to support new formatting

This PR implements the new GetConnectionProperties() method from the upstream Aspire PR #11938 for all CommunityToolkit resources that implement IResourceWithConnectionString.

Progress

  • Review upstream PR #11938 changes and understand the new interface requirements
  • Identify all CommunityToolkit resources implementing IResourceWithConnectionString
  • Implement GetConnectionProperties() for each resource following the patterns from upstream
    • ActiveMQ resources (base class)
    • EventStore resources
    • Flagd resources
    • GoFeatureFlag resources
    • KurrentDB resources ✨ ADDED
    • LavinMQ resources ✨ ADDED
    • MailPit resources
    • Meilisearch resources
    • Minio resources
    • Ollama resources (OllamaResource, OllamaModelResource, OpenWebUIResource)
    • PapercutSmtp resources
    • RavenDB resources (server and database)
    • Solr resources
    • Sqlite resources (SqliteResource and SqliteWebResource)
    • SurrealDb resources (server, namespace, and database)
  • Fix failing tests for Minio and SurrealDb
  • Verify all tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Adapt connection string generation to support new formatting</issue_title>
<issue_description>dotnet/aspire#11938 is going to introduce a new structure on how Aspire resources handle connection strings, so there's going to be a bit of work in the community toolkit to support this.

We will need to update all resources that generate connection strings to implement the new member from the interface, and return out the collection of parts rather than a constructed .NET-esq connection string.</issue_description>

Comments on the Issue (you are @copilot in this section)

@aaronpowell cc @sebastienros @aaronpowell > They're finally doing it, eh. Good stuff -- will you rev a major version for this? i.e. 10.x ?

Yep, it's coming as part of the next major release, and we'll have to rev to match it.</comment_new>

Fixes #889


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update connection string generation for new formatting Implement GetConnectionProperties for new connection string formatting Oct 22, 2025
Copilot finished work on behalf of aaronpowell October 22, 2025 05:21
Copilot AI requested a review from aaronpowell October 22, 2025 05:21
@davidfowl
Copy link
Contributor

cc @sebastienros

/// <inheritdoc />
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create(
$"{scheme}://{UserNameReference}:{PasswordParameter}@{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");
Copy link

@sebastienros sebastienros Oct 22, 2025

Choose a reason for hiding this comment

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

At what point will it be able to use the encoding from 13.0 (Password:uri)?

Copy link
Member

Choose a reason for hiding this comment

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

@sebastienros sorry, I'm not sure I'm following

Choose a reason for hiding this comment

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

You can add :uri formatter suffix on values that need to be url-encoded:

ReferenceExpression.Create(
            $"{scheme}://{UserNameReference}:{PasswordParameter:uri}@{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}");

Copy link
Member

Choose a reason for hiding this comment

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

Well, TIL.

@copilot can you do this

aaronpowell and others added 8 commits October 23, 2025 01:06
* Initial plan

* Replace IDistributedApplicationLifecycleHook with event-based patterns

Co-authored-by: aaronpowell <[email protected]>

* Add tests for installer resources and update Dapr tests

Co-authored-by: aaronpowell <[email protected]>

* Refactor Dapr to use IDistributedApplicationEventingSubscriber

Co-authored-by: aaronpowell <[email protected]>

* Fixing build issue

* Updating the endpoint port

* Disabling some tests so we can move forward in other parts of the Aspire 13 update

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: aaronpowell <[email protected]>
Co-authored-by: Aaron Powell <[email protected]>
@github-actions github-actions bot added the Stale label Nov 2, 2025
* Initial plan

* Remove AddViteApp and npm-specific functionality (moved to Aspire 13)

Co-authored-by: aaronpowell <[email protected]>

* Update comments and tests to reflect npm removal

Co-authored-by: aaronpowell <[email protected]>

* Update MONOREPO.md to remove npm references

Co-authored-by: aaronpowell <[email protected]>

* Adding missing types

* Bad copilot code

* Fixing missing namespace

* Handling port forwarding

* removing more stuff that has been migrated to aspire core

* Reworking how package installing is handled

* daily update

* Adding back the annotation that is no longer moving to core

* Forgot to install packages

* adding a bunch more annotations to provide enough metadata

* Removing old demo apps

* Disabling python tests

* Removing a testing change

* Updating to the latest nightly and dealing with type name changes

* Removing type that was can repurpose from aspire core

* breaking the tests down so they are easier to read

* Removing legacy docs

* Fixing failing tests

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: aaronpowell <[email protected]>
Co-authored-by: Aaron Powell <[email protected]>
@aaronpowell aaronpowell removed the Stale label Nov 3, 2025
@aaronpowell
Copy link
Member

Copilot finished work on behalf of aaronpowell November 4, 2025 05:17
Copy link
Contributor Author

Copilot AI commented Nov 4, 2025

@copilot the tests are for Hosting.Minio and Hosting.SurrealDb, with example logs https://github.com/CommunityToolkit/Aspire/actions/runs/19058298930/job/54432972325?pr=916 and https://github.com/Comm...

Fixed the failing tests. The issue was that MinioContainerResource, KurrentDBResource, and LavinMQContainerResource were missing the GetConnectionProperties() implementation required by the new IResourceWithConnectionString interface.

Added implementations in commits:

  • 9dd878d - MinioContainerResource
  • 750eeb7 - KurrentDBResource and LavinMQContainerResource

All resources now properly implement the connection properties interface following the same patterns as the upstream Aspire resources.

Copilot finished work on behalf of aaronpowell November 4, 2025 05:25

builder.Append($";AccessKey={RootUser}");
builder.Append($";SecretKey={PasswordParameter}");
builder.Append($";SecretKey={PasswordParameter:uri}");
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be URL-encoded, right?

Copy link
Member

Choose a reason for hiding this comment

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

My understanding from this thread #916 (comment) with @sebastienros was that passwords should be.

Choose a reason for hiding this comment

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

This one should not be "URL" encoded because it's not an url. We are not encoding connection string segments for now.

Base automatically changed from aspire-13 to main November 6, 2025 04:59
/// Gets the connection string expression for the Solr server.
/// </summary>
public ReferenceExpression ConnectionStringExpression => ReferenceExpression.Create(
$"http://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}/solr/{CoreName}");

Choose a reason for hiding this comment

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

Shouldn't CoreName be encoded?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe but it would also depend on whether the client is aware that it's URL encoded and knows to perform a decode. Since we don't have a Solr client we can't control the expectation.

Choose a reason for hiding this comment

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

What do you think a client would do with a URL? Split by '/' ? Also what if a client was actually reading the URL, this would break with any incompatible char then. This can always be changed later, not a big issue for now IMO


IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() =>
Parent.CombineProperties([
new("Database", ReferenceExpression.Create($"{DatabaseName}"))

Choose a reason for hiding this comment

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

If the parent has a Uri then this resource should too. And a good pattern is to then have the parent expression expose a BuildUri(string? database name) method.

Copy link
Member

Choose a reason for hiding this comment

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

Umm, I guess so? TBH I won't get that done this release. If you can create an issue and point it to the relevant changes in aspire I'll see if copilot can sort it out.

private ReferenceExpression ConnectionString =>
ReferenceExpression.Create(
$"Server={SchemeUri}://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}/rpc;User={UserNameReference};Password='{PasswordParameter}'");
$"Server={SchemeUri}://{PrimaryEndpoint.Property(EndpointProperty.Host)}:{PrimaryEndpoint.Property(EndpointProperty.Port)}/rpc;User={UserNameReference};Password={PasswordParameter}");

Choose a reason for hiding this comment

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

I didn't think you are using the latest version of aspire because this wouldn't compile anymore. Check BuildUri in MySql resource.

@sebastienros
Copy link

In the latest commit the title mentions an encode is removed because the client doesn't support it. To be clear it was used in a connection string for the property Password which is not a URL, so this shouldn't be url-encoded independently of what the client would be or do.

@aaronpowell
Copy link
Member

In the latest commit the title mentions an encode is removed because the client doesn't support it. To be clear it was used in a connection string for the property Password which is not a URL, so this shouldn't be url-encoded independently of what the client would be or do.

right - and I think this PR is now muddied in terms of what it needs to tackle and what would be good to tackle, so I'm going to strip it back and if we can get issues on the other stuff then I'll get that tackled elsewhere

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.GoFeatureFlag 100% 97% 74
CommunityToolkit.Aspire.Hosting.ActiveMQ 78% 40% 108
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Adminer 73% 50% 20
CommunityToolkit.Aspire.Hosting.Azure.Dapr 29% 7% 124
CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis 61% 34% 76
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Bun 96% 83% 28
CommunityToolkit.Aspire.Hosting.Dapr 60% 36% 836
CommunityToolkit.Aspire.Hosting.DbGate 94% 50% 18
CommunityToolkit.Aspire.Hosting.Deno 98% 85% 44
CommunityToolkit.Aspire.Hosting.Flagd 79% 100% 32
CommunityToolkit.Aspire.Hosting.GoFeatureFlag 87% 73% 36
CommunityToolkit.Aspire.Hosting.Golang 87% 70% 28
CommunityToolkit.Aspire.Hosting.Java 70% 75% 130
CommunityToolkit.Aspire.Hosting.k6 58% 12% 20
CommunityToolkit.Aspire.Hosting.Keycloak.Extensions 100% 100% 22
CommunityToolkit.Aspire.Hosting.KurrentDB 71% 75% 34
CommunityToolkit.Aspire.Hosting.LavinMQ 74% 50% 26
CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.MailPit 85% 50% 22
CommunityToolkit.Aspire.Hosting.McpInspector 75% 39% 150
CommunityToolkit.Aspire.Hosting.Meilisearch 71% 55% 58
CommunityToolkit.Aspire.Hosting.Minio 88% 75% 56
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 96% 83% 36
CommunityToolkit.Aspire.Hosting.MySql.Extensions 100% 88% 78
CommunityToolkit.Aspire.Hosting.Ngrok 52% 35% 82
CommunityToolkit.Aspire.Hosting.NodeJS.Extensions 97% 87% 168
CommunityToolkit.Aspire.Hosting.Ollama 64% 70% 192
CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector 78% 61% 77
CommunityToolkit.Aspire.Hosting.PapercutSmtp 81% 50% 18
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 99% 89% 84
CommunityToolkit.Aspire.Hosting.Python.Extensions 39% 32% 90
CommunityToolkit.Aspire.Hosting.RavenDB 62% 48% 148
CommunityToolkit.Aspire.Hosting.Redis.Extensions 100% 71% 48
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.Solr 72% 100% 22
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 52% 49% 206
CommunityToolkit.Aspire.Hosting.Sqlite 89% 89% 52
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 100% 87% 78
CommunityToolkit.Aspire.Hosting.SurrealDb 55% 40% 256
CommunityToolkit.Aspire.KurrentDB 94% 92% 54
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 89% 85% 52
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 61% 58% 114
CommunityToolkit.Aspire.Minio.Client 73% 59% 88
CommunityToolkit.Aspire.OllamaSharp 77% 71% 132
CommunityToolkit.Aspire.RavenDB.Client 60% 53% 237
CommunityToolkit.Aspire.SurrealDb 79% 63% 78
Summary 68% (6941 / 10206) 55% (1945 / 3522) 4496

Minimum allowed line rate is 60%

@aaronpowell aaronpowell merged commit e933788 into main Nov 11, 2025
108 checks passed
@aaronpowell aaronpowell deleted the copilot/adapt-connection-string-formatting branch November 11, 2025 04:51
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.

Adapt connection string generation to support new formatting

5 participants