{"record":{"id":"7e402755f207c1d8","repo":"microsoft/edit","slug":"no-matching-highlighting-definition-found","errorCode":null,"errorMessage":"No matching highlighting definition found","messagePattern":"No matching highlighting definition found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lsh-bin/src/main.rs","lineNumber":129,"sourceCode":"    path: Option<&Path>,\n    language: Option<&str>,\n) -> anyhow::Result<()> {\n    let assembly = generator.assemble()?;\n\n    let entrypoint = if let Some(language) = language {\n        assembly.entrypoints.iter().find(|ep| ep.name.replace('_', \"-\") == language).ok_or_else(\n            || anyhow::anyhow!(\"No highlighting definition found for language {language:?}\"),\n        )?\n    } else if let Some(path) = path {\n        assembly\n            .entrypoints\n            .iter()\n            .find(|ep| {\n                ep.paths.iter().any(|pattern| {\n                    glob_match(pattern.as_bytes(), path.as_os_str().as_encoded_bytes())\n                })\n            })\n            .ok_or_else(|| anyhow::anyhow!(\"No matching highlighting definition found\"))?\n    } else {\n        bail!(\"A language ID is required when reading from stdin\");\n    };\n\n    let mut color_map = Vec::new();\n    let mut unknown_kinds = Vec::new();\n    for hk in &assembly.highlight_kinds {\n        let color = match hk.identifier {\n            \"other\" => \"\",\n\n            \"comment\" => \"\\x1b[32m\",  // Green\n            \"method\" => \"\\x1b[93m\",   // Bright Yellow\n            \"string\" => \"\\x1b[91m\",   // Bright Red\n            \"variable\" => \"\\x1b[96m\", // Bright Cyan\n\n            \"constant.language\" => \"\\x1b[94m\",    // Bright Blue\n            \"constant.numeric\" => \"\\x1b[92m\",     // Bright Green\n            \"keyword.control\" => \"\\x1b[95m\",      // Bright Magenta","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/microsoft/edit/blob/826b4c097b6f14ba0a846dc56f2f0223a3aaf73a/crates/lsh-bin/src/main.rs#L111-L147","documentation":"When a file path is given instead of a language ID, run_render picks the first entrypoint whose glob `paths` patterns match the path. If no loaded definition's path patterns match the file, it errors; the binary cannot guess a highlighting definition for the file.","triggerScenarios":"Rendering a file whose name/extension matches none of the loaded entrypoints' path glob patterns, e.g. an extension the .lsh definitions do not declare.","commonSituations":"Rendering files with unusual extensions (.txt, custom extensions); definitions loaded but their `paths` globs were authored for different extensions; new file types added before updating the .lsh definition.","solutions":["Add the file's extension/glob to the `paths` patterns of the appropriate .lsh entrypoint.","Explicitly pass --language <id> instead of relying on path matching.","Load the definition set that covers the file type you are rendering."],"exampleFix":"// before (in .lsh definition)\npaths = [\"*.rs\"]\n// after\npaths = [\"*.rs\", \"*.rs.in\"]","handlingStrategy":"validation","validationCode":"fn is_covered(path: &str, entrypoint_globs: &[&str]) -> bool {\n    entrypoint_globs.iter().any(|g| glob_match(g.as_bytes(), path.as_bytes()))\n}\nif !is_covered(\"foo.weird-ext\", &GLOBS) { eprintln!(\"no definition covers this file; pass --language\"); }","typeGuard":null,"tryCatchPattern":"// fall back to explicit language when path matching fails\nlet out = Command::new(\"lsh\").arg(file).status()\n    .or_else(|_| Command::new(\"lsh\").args([\"--language\", \"plaintext\"]).arg(file).status())?;","preventionTips":["Add globs for every extension your project renders to the relevant .lsh `paths`.","Default to passing --language for files with uncommon extensions.","Add a test that renders each tracked file type so gaps surface early."],"tags":["cli","glob-match","language-detection"],"backgroundTag":"resource-not-found","analyzedSha":"826b4c097b6f14ba0a846dc56f2f0223a3aaf73a","analyzedAt":"2026-09-06T13:30:05.543Z","contentChangedAt":"2026-09-06T13:30:05.543Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}