microsoft/autogen · error · InvalidDataException
Invalid semantic kernel settings in user secrets, please pro
Error message
Invalid semantic kernel settings in user secrets, please provide configuration settings using instructions in the README.
What it means
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.
Source
Thrown at dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs:95
.AddEnvironmentVariables()
.Build();
return configuration.Get<KernelSettings>()
?? throw new InvalidDataException($"Invalid semantic kernel settings in '{configFile}', please provide configuration settings using instructions in the README.");
}
/// <summary>
/// Load the kernel settings from user secrets.
/// </summary>
internal static KernelSettings FromUserSecrets()
{
var configuration = new ConfigurationBuilder()
.AddUserSecrets<KernelSettings>()
.AddEnvironmentVariables()
.Build();
return configuration.Get<KernelSettings>()
?? throw new InvalidDataException("Invalid semantic kernel settings in user secrets, please provide configuration settings using instructions in the README.");
}
}
View on GitHub (pinned to 027ecf0a37)
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.
Example fix
# before # (user-secrets store empty -> InvalidDataException) # after cd dotnet/samples/dev-team/seed-memory dotnet user-secrets set "Endpoint" "https://myres.openai.azure.com/" dotnet user-secrets set "ApiKey" "<key>" dotnet user-secrets set "CompletionDeploymentOrModelId" "gpt-35-turbo" dotnet user-secrets set "EmbeddingDeploymentOrModelId" "text-embedding-ada-002" dotnet user-secrets list # verify all keys present
Defensive patterns
Strategy: validation
Validate before calling
var settings = new ConfigurationBuilder().AddUserSecrets<KernelSettings>().AddEnvironmentVariables().Build().Get<KernelSettings>();
if (settings is null || string.IsNullOrWhiteSpace(settings.ApiKey))
{
Console.Error.WriteLine("User secrets incomplete. Run: dotnet user-secrets list (in the project folder) and set every KernelSettings key.");
return;
} Type guard
static bool IsValidKernelSettings(KernelSettings? s) => s is not null && !string.IsNullOrWhiteSpace(s.Endpoint) && !string.IsNullOrWhiteSpace(s.ApiKey);
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Configuration not found: {configFile}
- Invalid semantic kernel settings in '{configFile}', please p
- Failed to get login URL
- Authentication failed
- Template ${templateId} not found for component type ${compon
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/15fc5d9a88fe6690.
Report an issue: GitHub.