{"record":{"id":"3910ed751fc08045","repo":"microsoft/aspire","slug":"connectionstringavailableevent-was-published-for-the-3910ed","errorCode":null,"errorMessage":"ConnectionStringAvailableEvent was published for the '{oracleDatabaseServer.Name}' resource but the connection string was null.","messagePattern":"ConnectionStringAvailableEvent was published for the '(.+?)' resource but the connection string was null\\.","errorType":"exception","errorClass":"DistributedApplicationException","httpStatus":null,"severity":"critical","filePath":"src/Aspire.Hosting.Oracle/OracleDatabaseBuilderExtensions.cs","lineNumber":51,"sourceCode":"        IResourceBuilder<ParameterResource>? password = null,\n        int? port = null)\n    {\n        ArgumentNullException.ThrowIfNull(builder);\n        ArgumentException.ThrowIfNullOrEmpty(name);\n\n        var passwordParameter = password?.Resource ?? ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $\"{name}-password\");\n\n        var oracleDatabaseServer = new OracleDatabaseServerResource(name, passwordParameter);\n\n        string? connectionString = null;\n\n        builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(oracleDatabaseServer, async (@event, ct) =>\n        {\n            connectionString = await oracleDatabaseServer.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false);\n\n            if (connectionString == null)\n            {\n                throw new DistributedApplicationException($\"ConnectionStringAvailableEvent was published for the '{oracleDatabaseServer.Name}' resource but the connection string was null.\");\n            }\n        });\n\n        var healthCheckKey = $\"{name}_check\";\n        builder.Services.AddHealthChecks()\n            .AddOracle(sp => connectionString ?? throw new InvalidOperationException(\"Connection string is unavailable\"), name: healthCheckKey);\n\n        return builder.AddResource(oracleDatabaseServer)\n                      .WithEndpoint(port: port, targetPort: 1521, name: OracleDatabaseServerResource.PrimaryEndpointName)\n                      .WithImage(OracleContainerImageTags.Image, OracleContainerImageTags.Tag)\n                      .WithImageRegistry(OracleContainerImageTags.Registry)\n                      .WithIconName(\"DatabaseMultiple\")\n                      .WithEnvironment(context =>\n                      {\n                          context.EnvironmentVariables[PasswordEnvVarName] = oracleDatabaseServer.PasswordParameter;\n                      })\n                      .WithHealthCheck(healthCheckKey);\n    }","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Oracle/OracleDatabaseBuilderExtensions.cs#L33-L69","documentation":"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.","triggerScenarios":"ConnectionStringAvailableEvent published for the OracleServerResource while oracleDatabaseServer.ConnectionStringExpression.GetValueAsync returns null — e.g. missing endpoint/port reference or parameter backing the connection string.","commonSituations":"Customized Oracle resource overriding the connection string incorrectly; running without required configuration; event published before the resource model is fully built.","solutions":["Verify the Oracle resource has a valid endpoint and connection-string backing (default AddOracle setup provides these).","If overriding ConnectionStringExpression, make sure it never returns null and fails earlier with a clearer message.","Re-check required parameters/config for the Oracle resource before the AppHost runs."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify Oracle resource has endpoint + credentials configured before run\nif (oracleResource.ConnectionStringExpression is null)\n{\n    throw new InvalidOperationException(\"Oracle resource has no connection string expression.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use stock AddOracle configuration; avoid overriding the connection string expression","Validate required parameters exist per environment","Do not publish lifecycle events manually"],"tags":["aspire","oracle","connection-string","eventing"],"backgroundTag":"internal-invariant-violation","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}