{"record":{"id":"83bb44d51624cae4","repo":"microsoft/aspire","slug":"qdrant-client-is-unavailable","errorCode":null,"errorMessage":"Qdrant Client is unavailable","messagePattern":"Qdrant Client is unavailable","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs","lineNumber":66,"sourceCode":"        var apiKeyParameter = apiKey?.Resource ??\n            ParameterResourceBuilderExtensions.CreateDefaultPasswordParameter(builder, $\"{name}-Key\", special: false);\n        var qdrant = new QdrantServerResource(name, apiKeyParameter);\n\n        QdrantClient? qdrantClient = null;\n\n        builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(qdrant, async (@event, ct) =>\n        {\n            var connectionString = await qdrant.ConnectionStringExpression.GetValueAsync(ct).ConfigureAwait(false)\n            ?? throw new DistributedApplicationException($\"ConnectionStringAvailableEvent was published for the '{qdrant.Name}' resource but the connection string was null.\");\n\n            qdrantClient = CreateQdrantClient(connectionString);\n        });\n\n        var healthCheckKey = $\"{name}_check\";\n        builder.Services.AddHealthChecks()\n          .Add(new HealthCheckRegistration(\n              healthCheckKey,\n              sp => new QdrantHealthCheck(qdrantClient ?? throw new InvalidOperationException(\"Qdrant Client is unavailable\")),\n              failureStatus: default,\n              tags: default,\n              timeout: default));\n\n        return builder.AddResource(qdrant)\n            .WithImage(QdrantContainerImageTags.Image, QdrantContainerImageTags.Tag)\n            .WithImageRegistry(QdrantContainerImageTags.Registry)\n            .WithIconName(\"DatabaseSearch\")\n            .WithHttpEndpoint(port: grpcPort, targetPort: QdrantPortGrpc, name: QdrantServerResource.PrimaryEndpointName)\n            .WithEndpoint(QdrantServerResource.PrimaryEndpointName, endpoint =>\n            {\n                endpoint.Transport = \"http2\";\n            })\n            .WithHttpEndpoint(port: httpPort, targetPort: QdrantPortHttp, name: QdrantServerResource.HttpEndpointName)\n            .WithEnvironment(context =>\n            {\n                context.EnvironmentVariables[ApiKeyEnvVarName] = qdrant.ApiKeyParameter;\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Qdrant/QdrantBuilderExtensions.cs#L48-L84","documentation":"AddQdrant registers a health check that needs a QdrantClient instance. If no client was provided or resolvable from the resource's connection string at registration time, the health check factory throws InvalidOperationException('Qdrant Client is unavailable') when it evaluates. This signals that the hosting code could not construct the client needed to probe Qdrant.","triggerScenarios":"Calling AddQdrant (or AddQdrant with an explicit connection string/reference) where neither a QdrantClient argument is passed nor a valid connection string/endpoint can be resolved, so the factory lambda `qdrantClient ?? throw new InvalidOperationException(...)` executes during a health check evaluation.","commonSituations":"Misconfigured or missing connection string on the Qdrant resource; calling an overload without supplying a client while the resource's connection string is not yet available; typos in the connection-name reference so CreateQdrantClient receives null.","solutions":["Ensure the Qdrant resource has a valid connection string (via RunWithConnectionString/callback or a proper reference) before the app starts.","Pass an explicit QdrantClient instance to AddQdrant if you construct one yourself (e.g. with endpoint and API key).","Verify the connection-name used with WithReference matches the resource name so the connection string resolves.","Check that CreateQdrantClient can parse the connection string as an absolute URI or key/value pair with an 'Endpoint' entry."],"exampleFix":"// before\nvar qdrant = builder.AddQdrant(\"qdrant\");\n\n// after\nvar qdrant = builder.AddQdrant(\"qdrant\", connectionString: \"Endpoint=http://localhost:6334;Key=secret\");","handlingStrategy":"validation","validationCode":"// Ensure connection info exists before the health check runs\nif (string.IsNullOrEmpty(connectionString) && qdrantClient is null)\n{\n    throw new InvalidOperationException(\"Provide a QdrantClient or a valid connection string before calling AddQdrant.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply an explicit connection string or client to AddQdrant in test/dev environments.","Confirm WithReference names match the Qdrant resource name.","Run the AppHost locally and verify ConnectionStrings__<name> resolves before deploying."],"tags":["qdrant","health-check","connection-string","aspire-hosting"],"backgroundTag":"missing-dependency","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"}