{"record":{"id":"47fcc99aed502706","repo":"microsoft/ailab","slug":"settingkey-can-t-be-empty","errorCode":null,"errorMessage":"[{settingKey}] can't be empty.","messagePattern":"\\[(.+?)\\] can't be empty\\.","errorType":"exception","errorClass":"SettingsPropertyNotFoundException","httpStatus":null,"severity":"critical","filePath":"JFKFiles/JfkWebApiSkills/JfkInitializer/Program.cs","lineNumber":315,"sourceCode":"        private static void CheckSettings()\n        {\n            CheckSetting(\"SearchServiceName\");\n            CheckSetting(\"SearchServiceApiKey\");\n            CheckSetting(\"SearchServiceQueryKey\");\n            CheckSetting(\"BlobStorageAccountConnectionString\");\n            CheckSetting(\"AzureWebAppSiteName\");\n            CheckSetting(\"AzureWebAppUsername\");\n            CheckSetting(\"AzureWebAppPassword\");\n            CheckSetting(\"AzureFunctionSiteName\");\n            CheckSetting(\"AzureFunctionHostKey\");\n        }\n\n        private static void CheckSetting(string settingKey)\n        {\n            var value = ConfigurationManager.AppSettings[settingKey];\n            if (string.IsNullOrEmpty(value))\n            {\n                throw new SettingsPropertyNotFoundException($\"[{settingKey}] can't be empty.\");\n            }\n        }\n    }\n}\n","sourceCodeStart":297,"sourceCodeEnd":320,"githubUrl":"https://github.com/microsoft/ailab/blob/89fe2fc62081145ec5408d42059cbcb7c4a033c8/JFKFiles/JfkWebApiSkills/JfkInitializer/Program.cs#L297-L320","documentation":"CheckSetting reads a key from ConfigurationManager.AppSettings (app.config / web.config appSettings) and throws SettingsPropertyNotFoundException if the value is null or empty. JFKFiles initialization requires every listed setting to be present, so any missing configuration entry aborts the program at startup via CheckSettings.","triggerScenarios":"Running JfkInitializer with an app.config that lacks any required appSettings key, or a key present with an empty value (e.g. <add key=\"X\" value=\"\"/>).","commonSituations":"Deploying the binary without its config file; copying app.config as App.config with wrong casing so it isn't picked up; new required settings added in a newer version while the old config is reused; Azure deployment missing the config transform.","solutions":["Open the app/web.config deployed next to JfkWebApiSkills.JfkInitializer.exe and add every required appSettings key with a non-empty value","The message names the exact missing key ([settingKey]); set that specific key first","Verify the config file is copied to the output directory (Copy to Output Directory = Copy always) and transforms applied on publish","Align config with the sample app.config shipped in the repo version you are building"],"exampleFix":"// before (app.config)\n<appSettings>\n  <add key=\"AzureSearchApiKey\" value=\"\" />\n</appSettings>\n// after\n<appSettings>\n  <add key=\"AzureSearchApiKey\" value=\"YOUR_KEY\" />\n</appSettings>","handlingStrategy":"validation","validationCode":"var keys = new[] { \"SettingA\", \"SettingB\" }; // required keys\nforeach (var k in keys)\n{\n    if (string.IsNullOrEmpty(ConfigurationManager.AppSettings[k]))\n        throw new ConfigurationErrorsException($\"[{k}] must be set in appSettings before starting\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    JfkInitializer.CheckSettings();\n}\ncatch (SettingsPropertyNotFoundException ex)\n{\n    Console.Error.WriteLine($\"Missing configuration: {ex.Message}. Update app.config appSettings.\");\n    Environment.Exit(2);\n}","preventionTips":["Keep app.config in sync with the sample config for your repo version","Set config files to 'Copy to Output Directory: Copy always'","Validate all required appSettings keys at startup with a single checks routine","Apply config transforms on publish and verify the deployed config"],"tags":["csharp","configuration","appsettings","startup"],"backgroundTag":"missing-config-key","analyzedSha":"89fe2fc62081145ec5408d42059cbcb7c4a033c8","analyzedAt":"2026-09-13T20:10:53.835Z","contentChangedAt":"2026-09-13T20:10:53.835Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}