{"record":{"id":"631e92aaa7a92a03","repo":"stride3d/stride","slug":"settings-key-not-found","errorCode":null,"errorMessage":"Settings key not found","messagePattern":"Settings key not found","errorType":"exception","errorClass":"KeyNotFoundException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Design/Settings/SettingsKey.cs","lineNumber":230,"sourceCode":"    /// Gets the value of this settings key in the current profile.\n    /// </summary>\n    /// <returns>The value of this settings key.</returns>\n    public T GetValue()\n    {\n        var profile = ResolveProfile();\n        if (profile.GetValue(Name, out var value, true, false))\n        {\n            try\n            {\n                return (T)value;\n            }\n            catch (Exception)\n            {\n                return DefaultValue;\n            }\n        }\n        // This should never happen\n        throw new KeyNotFoundException(\"Settings key not found\");\n    }\n\n    /// <summary>\n    /// Sets the value of this settings key in the given profile.\n    /// </summary>\n    /// <param name=\"value\">The new value to set.</param>\n    /// <param name=\"profile\">The profile in which to set the value. Must be a non-null that uses the same <see cref=\"SettingsContainer\"/> that this <see cref=\"SettingsKey\"/>.</param>\n    public void SetValue(T value, SettingsProfile profile)\n    {\n#if NET6_0_OR_GREATER\n        ArgumentNullException.ThrowIfNull(profile);\n#else\n        if (profile is null) throw new ArgumentNullException(nameof(profile));\n#endif\n        profile = ResolveProfile(profile);\n        profile.SetValue(Name, value);\n    }\n","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Design/Settings/SettingsKey.cs#L212-L248","documentation":"SettingsKeyT.GetValue walks the profile chain (profile values, then parent profiles, then the default value) and this KeyNotFoundException marks a terminal state that the library considers unreachable: the key reached the root profile without finding a slot or returning DefaultValue. It indicates corrupted key/container registration state.","triggerScenarios":"Calling GetValue on a key whose lookup path is broken — e.g. a key whose Container/registration state is inconsistent, or a profile chain where no level can answer for the key.","commonSituations":"Deserializing a settings profile saved by a different app version whose key set changed; manually constructing or patching SettingsKey/SettingsProfile internals in tests; a bug where the key was never registered with the container.","solutions":["Register the key properly with the container before reading (create keys via the container's supported registration path)","Re-save/reload the settings file with the current app version so key metadata matches","Update code that hit the catch-and-fallthrough path to return DefaultValue instead of continuing to the unreachable throw","Report/investigate as a library bug if it reproduces with normal registered keys"],"exampleFix":"// before\nvar v = myKey.GetValue(profile); // KeyNotFoundException on stale key\n// after\nvar v;\ntry { v = myKey.GetValue(profile); }\ncatch (KeyNotFoundException) { v = myKey.DefaultValue; }","handlingStrategy":"try-catch","validationCode":"var value = myKey.TryGetValue ? myKey.DefaultValue : myKey.GetValue(profile); // if a safe accessor exists, prefer it","typeGuard":null,"tryCatchPattern":"try { v = myKey.GetValue(profile); }\ncatch (KeyNotFoundException) { v = myKey.DefaultValue; }","preventionTips":["Register all settings keys before profiles are loaded","Regenerate settings files when the key schema changes between versions","Treat this exception as an internal-state bug: log the key/container state"],"tags":["settings","key-not-found","internal-state"],"backgroundTag":"record-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}