{"record":{"id":"b9b28dbd303c63ca","repo":"Automattic/harper","slug":"failed-to-load-curated-dictionary","errorCode":null,"errorMessage":"Failed to load curated dictionary: {}","messagePattern":"Failed to load curated dictionary: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"harper-core/src/spell/mutable_dictionary.rs","lineNumber":38,"sourceCode":"/// as it is much faster.\n///\n/// To combine the contents of multiple dictionaries, regardless of type, use\n/// [`super::MergedDictionary`].\n#[derive(Debug, Clone, Eq, PartialEq)]\npub struct MutableDictionary {\n    /// All English words\n    word_map: WordMap,\n}\n\n/// The uncached function that is used to produce the original copy of the\n/// curated dictionary.\nfn uncached_inner_new() -> Arc<MutableDictionary> {\n    MutableDictionary::from_rune_files(\n        include_str!(\"../../dictionary.dict\"),\n        include_str!(\"../../annotations.json\"),\n    )\n    .map(Arc::new)\n    .unwrap_or_else(|e| panic!(\"Failed to load curated dictionary: {}\", e))\n}\n\nstatic DICT: LazyLock<Arc<MutableDictionary>> = LazyLock::new(uncached_inner_new);\n\nimpl MutableDictionary {\n    pub fn new() -> Self {\n        Self {\n            word_map: WordMap::default(),\n        }\n    }\n\n    pub fn from_rune_files(word_list: &str, attr_list: &str) -> Result<Self, rune::Error> {\n        let word_list = parse_word_list(word_list)?;\n        let attr_list = AttributeList::parse(attr_list)?;\n\n        // There will be at _least_ this number of words\n        let mut word_map = WordMap::default();\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/Automattic/harper/blob/5fe7d5ab76492d83f3ecdbc3f1da83c75dcb6f83/harper-core/src/spell/mutable_dictionary.rs#L20-L56","documentation":"MutableDictionary's lazy static initializer panics if the curated dictionary bundled into the binary (dictionary.dict + annotations.json, via include_str!) fails to parse. Since the files are embedded at compile time, this panic indicates a corrupted/incompatible build artifact or a bug in the parser rather than a runtime environment problem.","triggerScenarios":"First use of the curated dictionary (DICT LazyLock) triggers uncached_inner_new; it panics if MutableDictionary::from_rune_files returns Err — e.g. the embedded dictionary file is corrupt, an incompatible format version, or a parsing bug after a dictionary format change.","commonSituations":"Building with a mismatched harper-core version or a stale build cache after a dictionary format change; custom forks that replaced dictionary.dict with malformed content; upstream regression in dictionary data.","solutions":["Run `cargo clean` (or remove target/) and rebuild to rule out stale embedded artifacts.","Verify dictionary.dict and annotations.json in harper-core are intact and match the current parser format.","Update harper-core to the latest release; if it persists, file a bug with the wrapped error message.","In application code, avoid relying on curated defaults and construct a dictionary explicitly to get a Result you can handle."],"exampleFix":"// before\nlet dict = MutableDictionary::curated(); // panics on failure\n// after\nlet dict = MutableDictionary::from_rune_files(DICT_PATH, ANNOTATIONS_PATH)\n    .unwrap_or_else(|e| eprintln!(\"dict load failed: {e}\"); MutableDictionary::new());","handlingStrategy":"fallback","validationCode":"// Compile-time/build check: ensure embedded assets exist and are non-empty\n// test: assert!(include_str!(\"../../dictionary.dict\").len() > 0);","typeGuard":null,"tryCatchPattern":"// Panic cannot be caught in-process; prefer fallible construction:\nlet dict = MutableDictionary::from_rune_files(dict_path, annotations_path)\n    .unwrap_or_else(|e| { log::error(\"curated dict failed: {e}\"); MutableDictionary::new() });","preventionTips":["Clean-rebuild after upgrading harper-core so embedded dictionary artifacts refresh.","Keep dictionary.dict and annotations.json in sync with the parser version in forks.","Pin harper-core versions and read changelogs for dictionary format changes."],"tags":["rust","dictionary","panic","initialization"],"backgroundTag":"file-read-failed","analyzedSha":"5fe7d5ab76492d83f3ecdbc3f1da83c75dcb6f83","analyzedAt":"2026-09-06T11:34:38.610Z","contentChangedAt":"2026-09-06T11:34:38.610Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}