{"record":{"id":"62ff5a6aa835a5dd","repo":"zed-industries/zed","slug":"no-default-value-for-setting","errorCode":null,"errorMessage":"no default value for setting {}","messagePattern":"no default value for setting (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/settings/src/settings_store.rs","lineNumber":1629,"sourceCode":"    }\n}\nimpl std::error::Error for InvalidSettingsError {}\n\nimpl Debug for SettingsStore {\n    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {\n        f.debug_struct(\"SettingsStore\")\n            .field(\n                \"types\",\n                &self\n                    .setting_values\n                    .values()\n                    .map(|value| value.setting_type_name())\n                    .collect::<Vec<_>>(),\n            )\n            .field(\"default_settings\", &self.default_settings)\n            .field(\"user_settings\", &self.user_settings)\n            .field(\"local_settings\", &self.local_settings)\n            .finish_non_exhaustive()\n    }\n}\n\nimpl<T: Settings> AnySettingValue for SettingValue<T> {\n    fn from_settings(&self, s: &SettingsContent) -> Box<dyn Any> {\n        Box::new(T::from_settings(s)) as _\n    }\n\n    fn setting_type_name(&self) -> &'static str {\n        type_name::<T>()\n    }\n\n    fn all_local_values(&self) -> Vec<(WorktreeId, Arc<RelPath>, &dyn Any)> {\n        self.local_values\n            .iter()\n            .map(|(id, path, value)| (*id, path.clone(), value as _))\n            .collect()\n    }","sourceCodeStart":1611,"sourceCodeEnd":1647,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/settings/src/settings_store.rs#L1611-L1647","documentation":"Each registered setting keeps its merged global value; value_for_path (crates/settings/src/settings_store.rs:1629) returns a matching local override or unwraps the global value, panicking when it is None. Registration normally sets the global value immediately (register_setting_internal), so in practice this panic means a SettingValue entry exists without its global value ever having been applied — an internal invariant break or a hand-built store in tests rather than a normal user flow.","triggerScenarios":"Calling get::<T> on a store whose entry for T was created but never received a global value: constructing SettingValue state directly in tests, or reading between entry creation and the set_global_value call in register_setting_internal (crates/settings/src/settings_store.rs:426-436). The doc on get() states it panics when 'there is no value for this setting'.","commonSituations":"Test helpers that poke the store's internals instead of going through register_setting; forks or refactor branches that construct SettingValue manually; nothing in the normal app flow.","solutions":["Register settings through register_setting / T::register(cx) so the global value is computed from merged settings content at registration time.","For reads that may hit unpopulated state, use try_get::<T>() which returns None instead of panicking.","If you build store state manually in tests, always follow with set_global_value/refresh before reading.","Check for code paths that reset or rebuild setting_values without re-applying defaults."],"exampleFix":"// before: hand-built entry without a global value\nstore.get::<MySettings>(None); // panics: no default value for setting\n\n// after: register through the normal path\nstore.register_setting::<MySettings>();\nstore.get::<MySettings>(None);","handlingStrategy":"validation","validationCode":"// prefer the non-panicking read when entry state is uncertain\nif let Some(value) = store.try_get::<MySettings>(None) {\n    // use value\n} else {\n    // register/refresh before reading\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always create setting entries via register_setting so the global value is set from merged content immediately.","Do not hand-construct SettingValue state in tests; use the store APIs.","Use try_get where population timing is uncertain."],"tags":["settings","default-value","panic","zed"],"backgroundTag":"missing-default-value","analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}