microsoft/aspire · critical · DistributedApplicationException

ConnectionStringAvailableEvent was published for the

Error message

ConnectionStringAvailableEvent was published for the '{oracleDatabaseServer.Name}' resource but the connection string was null.

What it means

AddOracle subscribes to ConnectionStringAvailableEvent for the Oracle database server resource and evaluates its ConnectionStringExpression when the event fires. If the expression yields null the resource model is broken (the event promises a connection string), so a DistributedApplicationException is thrown. The captured string also feeds the health check registration.

Solutions

  1. Verify the Oracle resource has a valid endpoint and connection-string backing (default AddOracle setup provides these).
  2. If overriding ConnectionStringExpression, make sure it never returns null and fails earlier with a clearer message.
  3. Re-check required parameters/config for the Oracle resource before the AppHost runs.
Defensive patterns

Strategy: validation

Validate before calling

// Verify Oracle resource has endpoint + credentials configured before run
if (oracleResource.ConnectionStringExpression is null)
{
    throw new InvalidOperationException("Oracle resource has no connection string expression.");
}

Prevention

When it happens

Trigger: ConnectionStringAvailableEvent published for the OracleServerResource while oracleDatabaseServer.ConnectionStringExpression.GetValueAsync returns null — e.g. missing endpoint/port reference or parameter backing the connection string.

Common situations: Customized Oracle resource overriding the connection string incorrectly; running without required configuration; event published before the resource model is fully built.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/3910ed751fc08045. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Oracle/OracleDatabaseBuilderExtensions.cs:51

        IResourceBuilder<ParameterResource>? password = null,
        int? port = null)
    {
        ArgumentNullException.ThrowIfNull(builder);
        ArgumentException.ThrowIfNullOrEmpty(name);

        var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $"{name}-password");

        var oracleDatabaseServer = new OracleDatabaseServerResource(name, passwordParameter);

        string? connectionString = null;

        builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(oracleDatabaseServer, async (@event, ct) =>
        {
            connectionString = await oracleDatabaseServer.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false);

            if (connectionString == null)
            {
                throw new DistributedApplicationException($"ConnectionStringAvailableEvent was published for the '{oracleDatabaseServer.Name}' resource but the connection string was null.");
            }
        });

        var healthCheckKey = $"{name}_check";
        builder.Services.AddHealthChecks()
            .AddOracle(sp => connectionString ?? throw new InvalidOperationException("Connection string is unavailable"), name: healthCheckKey);

        return builder.AddResource(oracleDatabaseServer)
                      .WithEndpoint(port: port, targetPort: 1521, name: OracleDatabaseServerResource.PrimaryEndpointName)
                      .WithImage(OracleContainerImageTags.Image, OracleContainerImageTags.Tag)
                      .WithImageRegistry(OracleContainerImageTags.Registry)
                      .WithIconName("DatabaseMultiple")
                      .WithEnvironment(context =>
                      {
                          context.EnvironmentVariables[PasswordEnvVarName] = oracleDatabaseServer.PasswordParameter;
                      })
                      .WithHealthCheck(healthCheckKey);
    }

View on GitHub (pinned to 25830f84bd)