{"record":{"id":"6401bbf1f3c6b9f9","repo":"microsoft/aspire","slug":"connection-string-is-unavailable-qdrantbuilderextensions","errorCode":null,"errorMessage":"Connection string is unavailable","messagePattern":"Connection string is unavailable","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs","lineNumber":198,"sourceCode":"        {\n            builder.WithEnvironment(context =>\n            {\n                // primary endpoint (gRPC)\n                context.EnvironmentVariables[$\"{connectionStringName}\"] = qdrantResource.Resource.ConnectionStringExpression;\n\n                // HTTP endpoint\n                context.EnvironmentVariables[$\"{connectionStringName}_{QdrantServerResource.HttpEndpointName}\"] = qdrantResource.Resource.HttpConnectionStringExpression;\n            });\n        }\n\n        return builder;\n    }\n\n    private static QdrantClient CreateQdrantClient(string? connectionString)\n    {\n        if (connectionString is null)\n        {\n            throw new InvalidOperationException(\"Connection string is unavailable\");\n        }\n\n        Uri? endpoint = null;\n        string? key = null;\n\n        if (Uri.TryCreate(connectionString, UriKind.Absolute, out var uri))\n        {\n            endpoint = uri;\n        }\n        else\n        {\n            var connectionBuilder = new DbConnectionStringBuilder\n            {\n                ConnectionString = connectionString\n            };\n\n            if (connectionBuilder.TryGetValue(\"Endpoint\", out var endpointValue) && Uri.TryCreate(endpointValue.ToString(), UriKind.Absolute, out var serviceUri))\n            {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L180-L216","documentation":"CreateQdrantClient builds a QdrantClient from the resource's connection string. When the connection string is null — meaning no connection information was ever associated with the Qdrant resource — it throws InvalidOperationException('Connection string is unavailable'). The library requires at least a connection string to derive an endpoint for the client.","triggerScenarios":"AddQdrant invoked without a client and the resolved connection string parameter is null, e.g. the resource has no ConnectionStringExpression value and no explicit connection string argument was supplied.","commonSituations":"Forgetting to call RunWithConnectionString or not setting a connection string on the Qdrant resource; referencing the resource by a mismatched name; creating the resource in publish-only scenarios where the runtime value is absent.","solutions":["Provide a connection string via AddQdrant's connectionString parameter or a callback that returns one.","Set up the resource's connection string with WithReference/RunWithConnectionString so it resolves at runtime.","Verify the resource name used in WithReference matches the Qdrant resource name.","Inspect the resolved configuration (e.g. ConnectionStrings__qdrant) to confirm the value exists."],"exampleFix":"// before\nvar qdrant = builder.AddQdrant(\"qdrant\");\n\n// after\nvar qdrant = builder.AddQdrant(\"qdrant\", connectionString: builder.Configuration.GetConnectionString(\"qdrant\"));","handlingStrategy":"validation","validationCode":"var cs = builder.Configuration.GetConnectionString(\"qdrant\");\nif (string.IsNullOrEmpty(cs))\n{\n    throw new InvalidOperationException(\"Set ConnectionStrings:qdrant before starting the AppHost.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep connection strings in appsettings or user secrets keyed by the resource name.","Prefer AddQdrant overloads that take a connection string explicitly.","Check publish-mode vs run-mode differences that can leave the value unset."],"tags":["qdrant","connection-string","aspire-hosting"],"backgroundTag":"missing-required-config-field","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}