{"record":{"id":"15fc5d9a88fe6690","repo":"microsoft/autogen","slug":"invalid-semantic-kernel-settings-in-user-secrets","errorCode":null,"errorMessage":"Invalid semantic kernel settings in user secrets, please provide configuration settings using instructions in the README.","messagePattern":"Invalid semantic kernel settings in user secrets, please provide configuration settings using instructions in the README\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs","lineNumber":95,"sourceCode":"            .AddEnvironmentVariables()\n            .Build();\n\n        return configuration.Get<KernelSettings>()\n               ?? throw new InvalidDataException($\"Invalid semantic kernel settings in '{configFile}', please provide configuration settings using instructions in the README.\");\n    }\n\n    /// <summary>\n    /// Load the kernel settings from user secrets.\n    /// </summary>\n    internal static KernelSettings FromUserSecrets()\n    {\n        var configuration = new ConfigurationBuilder()\n            .AddUserSecrets<KernelSettings>()\n            .AddEnvironmentVariables()\n            .Build();\n\n        return configuration.Get<KernelSettings>()\n               ?? throw new InvalidDataException(\"Invalid semantic kernel settings in user secrets, please provide configuration settings using instructions in the README.\");\n    }\n}\n","sourceCodeStart":77,"sourceCodeEnd":98,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs#L77-L98","documentation":"The user-secrets counterpart of error 91: configuration built from AddUserSecrets<KernelSettings>() plus environment variables binds to null, so FromUserSecrets throws InvalidDataException. This means the dotnet user-secrets store for the project is empty or does not contain properties matching KernelSettings.","triggerScenarios":"Calling KernelSettings.FromUserSecrets() before running 'dotnet user-secrets set ...' for every required key; running user-secrets under a different project/UserSecretsId than the one populated; secrets stored with key names that don't match KernelSettings properties.","commonSituations":"Team onboarding where the README's user-secrets step was skipped; secrets set on the solution root project but the seed-memory tool has its own UserSecretsId; secrets set on Windows then running inside WSL (user-secrets store is per-OS/per-user); 'dotnet user-secrets set Key value' run in the wrong directory.","solutions":["From the seed-memory project directory, set each required secret: dotnet user-secrets set \"Endpoint\" \"https://<res>.openai.azure.com/\" etc., using the exact KernelSettings property names.","Verify what is stored: dotnet user-secrets list (run in the project folder).","Check the csproj's UserSecretsId matches the store you populated (both projects sharing one id avoids duplication).","As a fallback, create the JSON config file and use FromFile() instead."],"exampleFix":"# before\n# (user-secrets store empty -> InvalidDataException)\n\n# after\ncd dotnet/samples/dev-team/seed-memory\ndotnet user-secrets set \"Endpoint\" \"https://myres.openai.azure.com/\"\ndotnet user-secrets set \"ApiKey\" \"<key>\"\ndotnet user-secrets set \"CompletionDeploymentOrModelId\" \"gpt-35-turbo\"\ndotnet user-secrets set \"EmbeddingDeploymentOrModelId\" \"text-embedding-ada-002\"\ndotnet user-secrets list   # verify all keys present","handlingStrategy":"validation","validationCode":"var settings = new ConfigurationBuilder().AddUserSecrets<KernelSettings>().AddEnvironmentVariables().Build().Get<KernelSettings>();\nif (settings is null || string.IsNullOrWhiteSpace(settings.ApiKey))\n{\n    Console.Error.WriteLine(\"User secrets incomplete. Run: dotnet user-secrets list (in the project folder) and set every KernelSettings key.\");\n    return;\n}","typeGuard":"static bool IsValidKernelSettings(KernelSettings? s) => s is not null && !string.IsNullOrWhiteSpace(s.Endpoint) && !string.IsNullOrWhiteSpace(s.ApiKey);","tryCatchPattern":null,"preventionTips":["Run 'dotnet user-secrets list' from the project directory to verify keys exist before launching the tool.","Share one UserSecretsId across related projects in a sample so secrets set once apply everywhere.","Remember user secrets are per-machine and per-OS: re-set them inside WSL/containers."],"tags":["user-secrets","configuration","seed-memory","dev-team-sample","dotnet-cli"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}