{"record":{"id":"54f1f7a2f3d643f6","repo":"zed-industries/zed","slug":"failed-to-parse-cpp-semantic-token-rules-json","errorCode":null,"errorMessage":"failed to parse cpp semantic_token_rules.json","messagePattern":"failed to parse cpp semantic_token_rules\\.json","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/languages/src/cpp.rs","lineNumber":8,"sourceCode":"use settings::SemanticTokenRules;\n\npub(crate) fn semantic_token_rules() -> SemanticTokenRules {\n    let content = grammars::get_file(\"cpp/semantic_token_rules.json\")\n        .expect(\"missing cpp/semantic_token_rules.json\");\n    let json = std::str::from_utf8(&content.data).expect(\"invalid utf-8 in semantic_token_rules\");\n    settings::parse_json_with_comments::<SemanticTokenRules>(json)\n        .expect(\"failed to parse cpp semantic_token_rules.json\")\n}\n\n#[cfg(test)]\nmod tests {\n    use gpui::{AppContext as _, BorrowAppContext, TestAppContext};\n    use language::{AutoindentMode, Buffer};\n    use settings::SettingsStore;\n    use std::num::NonZeroU32;\n    use unindent::Unindent;\n\n    #[gpui::test]\n    async fn test_cpp_autoindent_switch_case(cx: &mut TestAppContext) {\n        cx.update(|cx| {\n            let test_settings = SettingsStore::test(cx);\n            cx.set_global(test_settings);\n            cx.update_global::<SettingsStore, _>(|store, cx| {\n                store.update_user_settings(cx, |s| {\n                    s.project.all_languages.defaults.tab_size = NonZeroU32::new(2);","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/languages/src/cpp.rs#L1-L26","documentation":"Panics when parse_json_with_comments fails on the cpp semantic-token rules JSON: after the asset was found and decoded, the JSONC text did not deserialize into SemanticTokenRules. Since both the schema type and the file are vendored together, a parse failure means the file's structure and the Rust type have drifted (or the file was hand-edited incorrectly).","triggerScenarios":"Thrown at crates/languages/src/cpp.rs:8 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the deserialization in a test to see the exact serde error and fix either the JSON file or SemanticTokenRules","Keep a round-trip test that serializes a sample SemanticTokenRules and re-parses the shipped file","Log and fall back to default rules instead of panicking when parsing fails"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}