Skip to content

Fix DbGate Redis connectivity by using TLS Redis URLs#1425

Merged
aaronpowell merged 3 commits into
mainfrom
copilot/fix-dbgate-redis-connection-issue
Jul 7, 2026
Merged

Fix DbGate Redis connectivity by using TLS Redis URLs#1425
aaronpowell merged 3 commits into
mainfrom
copilot/fix-dbgate-redis-connection-issue

Conversation

Copilot AI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

DbGate could not connect to Redis in newer Aspire/Redis combinations because the Redis connection URL generated by WithDbGate() used a non-TLS scheme, while Redis expected TLS. This updates the generated URL format to align with current Redis defaults used in the integration.

  • Redis DbGate URL generation

    • Updated Redis URL construction in RedisBuilderExtensions.WithDbGate() from redis:// to rediss://.
    • Applies to both password and non-password URL forms.
  • Test expectation alignment

    • Updated Redis URL assertions in:
      • CommunityToolkit.Aspire.Hosting.Redis.Extensions.Tests/ResourceCreationTests
      • CommunityToolkit.Aspire.Hosting.DbGate.Tests/AddDbGateTests
    • Expected DbGate env vars now assert rediss://... for Redis connections.
  • Behavioral effect

    • DbGate now receives Redis connection definitions that match TLS-enabled Redis endpoints, avoiding protocol mismatch timeouts.
var redisUrl = redisResource.PasswordParameter is not null
    ? ReferenceExpression.Create($"rediss://:{redisResource.PasswordParameter}@{name}:{redisResource.PrimaryEndpoint.TargetPort}")
    : ReferenceExpression.Create($"rediss://{name}:{redisResource.PrimaryEndpoint.TargetPort}");

Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix DbGate connection timeout with Redis in latest versions Fix DbGate Redis connectivity by using TLS Redis URLs Jun 24, 2026
Copilot AI requested a review from aaronpowell June 24, 2026 06:01
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 1425

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 1425"

@ebaskoro

ebaskoro commented Jul 4, 2026

Copy link
Copy Markdown

Looks like the build failed due to MessagePack version 2.5.192 referenced via Microsoft.SqlServer.DacFx in the SqlDatabaseProjects has moderate severity vulnerability. The project already suppresses NU1903 (high severity) but not NU1902 (moderate severity). Suggesting to add NU1902. However the real fix is probably to wait for Microsoft.SqlServer.DacFx to ship an update that bumps MessagePack to a non-vulnerable version.

@aaronpowell
aaronpowell marked this pull request as ready for review July 7, 2026 04:18
@aaronpowell
aaronpowell requested a review from Alirexaa as a code owner July 7, 2026 04:18
Copilot AI review requested due to automatic review settings July 7, 2026 04:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Redis → DbGate connection URL generated by RedisBuilderExtensions.WithDbGate() to use the TLS Redis scheme (rediss://) so DbGate can connect to TLS-enabled Redis endpoints in newer Aspire/Redis combinations.

Changes:

  • Updated Redis DbGate URL generation from redis:// to rediss:// (password and non-password forms).
  • Updated unit test expectations to assert rediss://... for the Redis DbGate URL env var.
Show a summary per file
File Description
tests/CommunityToolkit.Aspire.Hosting.Redis.Extensions.Tests/ResourceCreationTests.cs Updates expected Redis DbGate URL scheme to rediss:// in assertions.
tests/CommunityToolkit.Aspire.Hosting.DbGate.Tests/AddDbGateTests.cs Updates expected Redis URL scheme to rediss:// in multi-database DbGate env var assertions.
src/CommunityToolkit.Aspire.Hosting.Redis.Extensions/RedisBuilderExtensions.cs Switches DbGate Redis URL generation to rediss:// when constructing URL_* environment variables.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines 123 to +126
// DbGate assumes Redis is being accessed over a default Aspire container network and hardcodes the resource address
var redisUrl = redisResource.PasswordParameter is not null ?
ReferenceExpression.Create($"redis://:{redisResource.PasswordParameter}@{name}:{redisResource.PrimaryEndpoint.TargetPort?.ToString()}") :
ReferenceExpression.Create($"redis://{name}:{redisResource.PrimaryEndpoint.TargetPort?.ToString()}");
ReferenceExpression.Create($"rediss://:{redisResource.PasswordParameter}@{name}:{redisResource.PrimaryEndpoint.TargetPort?.ToString()}") :
ReferenceExpression.Create($"rediss://{name}:{redisResource.PrimaryEndpoint.TargetPort?.ToString()}");
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.Hosting.DbGate 96% 62% 12
CommunityToolkit.Aspire.Hosting.Dbx 94% 59% 68
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 88% 69% 18
CommunityToolkit.Aspire.Hosting.MySql.Extensions 51% 32% 44
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 43% 37% 54
CommunityToolkit.Aspire.Hosting.Redis.Extensions 92% 68% 22
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 46% 29% 48
Summary 66% (334 / 504) 45% (80 / 178) 266

@aaronpowell
aaronpowell temporarily deployed to azure-artifacts July 7, 2026 04:25 — with GitHub Actions Inactive
@aaronpowell
aaronpowell merged commit 0ca767a into main Jul 7, 2026
20 checks passed
@aaronpowell
aaronpowell deleted the copilot/fix-dbgate-redis-connection-issue branch July 7, 2026 04:50
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.

4 participants