{"record":{"id":"c395c69eb02f2971","repo":"microsoft/autogen","slug":"invalid-semantic-kernel-settings-in-configfile","errorCode":null,"errorMessage":"Invalid semantic kernel settings in '{configFile}', please provide configuration settings using instructions in the README.","messagePattern":"Invalid semantic kernel settings in '(.+?)', 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":81,"sourceCode":"\n    /// <summary>\n    /// Load the kernel settings from the specified configuration file if it exists.\n    /// </summary>\n    internal static KernelSettings FromFile(string configFile = DefaultConfigFile)\n    {\n        if (!File.Exists(configFile))\n        {\n            throw new FileNotFoundException($\"Configuration not found: {configFile}\");\n        }\n\n        var configuration = new ConfigurationBuilder()\n            .SetBasePath(Directory.GetCurrentDirectory())\n            .AddJsonFile(configFile, optional: true, reloadOnChange: true)\n            .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":63,"sourceCodeEnd":98,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs#L63-L98","documentation":"Thrown when the settings JSON file exists but configuration.Get<KernelSettings>() returns null — i.e. the file parsed yet produced no bindable KernelSettings instance (typically an empty file, wrong JSON shape, or a root object whose properties do not match the KernelSettings keys). It tells you to fix the file contents per the README rather than create it.","triggerScenarios":"appsettings.json exists but is empty ('{}' or blank); property names in the JSON don't match KernelSettings bindings (casing aside, wrong key names); JSON is an array or has the settings nested one level too deep so nothing binds at the root.","commonSituations":"Copy-pasted a config template from a different project; left the placeholder file from the repo in place; renamed KernelSettings properties between versions so old config files stop binding; nested the settings under a 'Kernel' section instead of the root.","solutions":["Open the file and fill in real values matching the KernelSettings property names exactly (see the class in the same config folder).","Ensure the JSON root object directly contains the settings keys — no extra wrapping section.","Validate locally: var k = configuration.Get<KernelSettings>(); Debug.Assert(k is not null);","If the file cannot hold secrets, move the values to user secrets and call FromUserSecrets() instead."],"exampleFix":"// before\n{ }\n\n// after (match KernelSettings property names at the root)\n{\n  \"Endpoint\": \"https://<res>.openai.azure.com/\",\n  \"ApiKey\": \"<key>\",\n  \"CompletionDeploymentOrModelId\": \"gpt-35-turbo\",\n  \"EmbeddingDeploymentOrModelId\": \"text-embedding-ada-002\"\n}","handlingStrategy":"validation","validationCode":"var settings = configuration.Get<KernelSettings>();\nif (settings is null || string.IsNullOrWhiteSpace(settings.ApiKey))\n{\n    Console.Error.WriteLine(\"KernelSettings did not bind: check that the JSON root contains the expected keys (Endpoint, ApiKey, deployment ids).\");\n    return;\n}","typeGuard":"static bool IsValidKernelSettings(KernelSettings? s) => s is not null && !string.IsNullOrWhiteSpace(s.Endpoint) && !string.IsNullOrWhiteSpace(s.ApiKey);","tryCatchPattern":"try { return configuration.Get<KernelSettings>() ?? throw new InvalidDataException(...); } catch (InvalidDataException) { /* print the expected key list from README and the keys actually present */ }","preventionTips":["After loading, assert the critical members (Endpoint/ApiKey/deployment ids) individually — a non-null bind with empty strings is equally broken.","Keep a validated example config in the README and diff your file's key names against KernelSettings properties after upgrades."],"tags":["configuration","json-binding","seed-memory","dev-team-sample","invalid-data"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}