{"record":{"id":"eea5ef03c2b7598e","repo":"zed-industries/zed","slug":"missing-config-for-language","errorCode":null,"errorMessage":"missing config for language {:?}","messagePattern":"missing config for language (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/grammars/src/grammars.rs","lineNumber":49,"sourceCode":"        (\"json\", tree_sitter_json::LANGUAGE.into()),\n        (\"jsonc\", tree_sitter_json::LANGUAGE.into()),\n        (\"markdown\", tree_sitter_md::LANGUAGE.into()),\n        (\"markdown-inline\", tree_sitter_md::INLINE_LANGUAGE.into()),\n        (\"python\", tree_sitter_python::LANGUAGE.into()),\n        (\"regex\", tree_sitter_regex::LANGUAGE.into()),\n        (\"rust\", tree_sitter_rust::LANGUAGE.into()),\n        (\"tsx\", tree_sitter_typescript::LANGUAGE_TSX.into()),\n        (\n            \"typescript\",\n            tree_sitter_typescript::LANGUAGE_TYPESCRIPT.into(),\n        ),\n        (\"yaml\", tree_sitter_yaml::LANGUAGE.into()),\n        (\"gitcommit\", tree_sitter_gitcommit::LANGUAGE.into()),\n    ]\n}\n\n/// Load and parse the `config.toml` for a given language name.\npub fn load_config(name: &str) -> LanguageConfig {\n    let config_toml = String::from_utf8(\n        GrammarDir::get(&format!(\"{}/config.toml\", name))\n            .unwrap_or_else(|| panic!(\"missing config for language {:?}\", name))\n            .data\n            .to_vec(),\n    )\n    .unwrap();\n\n    let config = LanguageConfig::from_toml(&config_toml)\n        .with_context(|| format!(\"failed to load config.toml for language {name:?}\"))\n        .unwrap();\n\n    config\n}\n\n/// Load and parse the `config.toml` for a given language name, stripping fields\n/// that require grammar support when grammars are not loaded.\npub fn load_config_for_feature(name: &str, grammars_loaded: bool) -> LanguageConfig {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/grammars/src/grammars.rs#L31-L67","documentation":"The grammars crate embeds each language's config.toml at compile time via a directory embed and looks it up by name in load_config(name). If no embedded file matches \"<name>/config.toml\", it panics with 'missing config for language'. The function returns LanguageConfig directly (not a Result), so a missing file is treated as a programmer error: every language name reaching this API must have shipped a config.","triggerScenarios":"Calling grammars::load_config(name) where name has no embedded config.toml: a newly added tree-sitter grammar whose config file was never created, a renamed language, or a caller passing an unvalidated string ('Rust' instead of 'rust', a grammar id that is not a built-in language).","commonSituations":"Contributors adding a grammar but forgetting the embedded config.toml; a stale build cache where the embed macro did not pick up newly added files until a clean rebuild; feeding arbitrary language identifiers from settings or LSP into load_config.","solutions":["Create the missing config.toml in the grammars crate's embedded languages directory using the path pattern <languages-root>/<name>/config.toml","Check exact name spelling and casing against the registered grammar ids (lowercase names like 'typescript', 'gitcommit')","cargo clean (or touch the grammars crate) so the embedded-directory macro re-scans and includes the new file","If the name comes from user input, validate it against the known built-in language list before calling load_config"],"exampleFix":"// before: panics for any unknown name\nlet config = grammars::load_config(&language_name);\n\n// after: check the embedded tree first and fail softly\nlet config = match GrammarDir::get(&format!(\"{}/config.toml\", language_name)) {\n    Some(file) => toml::from_str(std::str::from_utf8(&file.data)?)?,\n    None => return Err(anyhow!(\"no built-in grammar config for {language_name}\")),\n};","handlingStrategy":"validation","validationCode":"// check the embedded tree before calling load_config\npub fn has_config(name: &str) -> bool {\n    GrammarDir::get(&format!(\"{}/config.toml\", name)).is_some()\n}\n\nlet config = if has_config(name) {\n    Some(grammars::load_config(name))\n} else {\n    None // or fall back to a default LanguageConfig\n};","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a test that iterates every language id used in the crate and asserts load_config succeeds","Validate user-supplied language names against the static built-in list before lookup","Re-run a clean build after adding embedded files; include-directory macros cache aggressively"],"tags":["tree-sitter","grammars","config","embedded-resources","build"],"backgroundTag":"missing-embedded-resource","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}