{"record":{"id":"b4e0ba0ed4c6abb7","repo":"microsoft/aspire","slug":"a-milvusclient-could-not-be-configured-ensure-valid","errorCode":null,"errorMessage":"A MilvusClient could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:{connectionName}' or either {nameof(settings.Endpoint)} and {nameof(settings.Key)} must both be provided in the '{DefaultConfigSectionName}' or '{DefaultConfigSectionName}:{connectionName}' configuration sections.","messagePattern":"A MilvusClient could not be configured\\. Ensure valid connection information was provided in 'ConnectionStrings:(.+?)' or either (.+?) and (.+?) must both be provided in the '(.+?)' or '(.+?):(.+?)' configuration sections\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/Components/Aspire.Milvus.Client/AspireMilvusExtensions.cs","lineNumber":108,"sourceCode":"            builder.TryAddHealthCheck(new HealthCheckRegistration(\n                serviceKey is null ? \"Milvus\" : $\"Milvus_{connectionName}\",\n                sp => new MilvusHealthCheck(serviceKey is null\n                    ? sp.GetRequiredService<MilvusClient>()\n                    : sp.GetRequiredKeyedService<MilvusClient>(serviceKey)),\n                failureStatus: default,\n                tags: default,\n                timeout: default));\n        }\n\n        MilvusClient ConfigureMilvus(IServiceProvider serviceProvider)\n        {\n            if (settings.Endpoint is not null && settings.Key is not null)\n            {\n                return new MilvusClient(settings.Endpoint, apiKey: settings.Key, database: settings.Database, loggerFactory: serviceProvider.GetRequiredService<ILoggerFactory>());\n            }\n            else\n            {\n                throw new InvalidOperationException(\n                        $\"A MilvusClient could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:{connectionName}' or either \" +\n                        $\"{nameof(settings.Endpoint)} and {nameof(settings.Key)} must both be provided \" +\n                        $\"in the '{DefaultConfigSectionName}' or '{DefaultConfigSectionName}:{connectionName}' configuration sections.\");\n            }\n        }\n    }\n}\n","sourceCodeStart":90,"sourceCodeEnd":116,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Components/Aspire.Milvus.Client/AspireMilvusExtensions.cs#L90-L116","documentation":"MilvusClient creation requires an endpoint and an API key (or a connection string that supplies both). If, after config binding, either settings.Endpoint or settings.Key is null, the singleton factory throws because MilvusClient cannot be constructed. Both must be present together in the config sections or combined in the connection string.","triggerScenarios":"Resolving a client registered with AddMilvusClient/AddKeyedMilvusClient when ConnectionStrings:{connectionName} is absent and 'Aspire:Milvus:Client' (or the per-connection-name section) does not contain both Endpoint and Key.","commonSituations":"Milvus container not referenced in the AppHost so no connection string is emitted; only the endpoint configured but the auth key forgotten (or vice versa); using username/password-style Milvus auth that doesn't map to the Key field; environment-specific appsettings dropping the section.","solutions":["Provide the full connection string in 'ConnectionStrings:{connectionName}' (endpoint and key combined).","Or set both Endpoint and Key in the 'Aspire:Milvus:Client' or 'Aspire:Milvus:Client:{connectionName}' section — both keys are required together.","Add WithReference(milvus) in the AppHost so the connection string is injected.","Check for typos in the connection name and section keys."],"exampleFix":"// before (appsettings.json)\n{ \"Aspire\": { \"Milvus\": { \"Client\": { \"Endpoint\": \"http://localhost:19530\" } } } }\n// after\n{ \"Aspire\": { \"Milvus\": { \"Client\": { \"Endpoint\": \"http://localhost:19530\", \"Key\": \"root:Milvus\" } } } }","handlingStrategy":"validation","validationCode":"// before resolving the Milvus client\nvar cs = builder.Configuration.GetConnectionString(connectionName);\nvar section = builder.Configuration.GetSection(\"Aspire:Milvus:Client\");\nif (string.IsNullOrEmpty(cs) && (section[\"Endpoint\"] is null || section[\"Key\"] is null))\n{\n    throw new InvalidOperationException($\"Milvus endpoint and key must both be provided for '{connectionName}'.\");\n}","typeGuard":"bool HasMilvusInfo(string? cs, string? endpoint, string? key) => !string.IsNullOrEmpty(cs) || (endpoint is not null && key is not null);","tryCatchPattern":"try { var client = sp.GetRequiredService<MilvusClient>(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"A MilvusClient could not be configured\")) { logger.LogCritical(ex, \"Milvus connection info incomplete for {ConnectionName}\", connectionName); throw; }","preventionTips":["Always configure Endpoint and Key together — they are only valid as a pair.","Use WithReference(milvus) in the AppHost so the combined connection string is injected.","Confirm Docker/API-key auth is set up on the Milvus container (e.g. root:Milvus)."],"tags":["milvus","missing-credentials","missing-connection-string","configuration"],"backgroundTag":"missing-required-config","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"}