{"record":{"id":"cd58e76509e05dd9","repo":"zed-industries/zed","slug":"failed-to-parse-python-semantic-token-rules-json","errorCode":null,"errorMessage":"failed to parse python semantic_token_rules.json","messagePattern":"failed to parse python semantic_token_rules\\.json","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/languages/src/python.rs","lineNumber":60,"sourceCode":"use http_client::github_download::{GithubBinaryMetadata, download_server_binary};\nuse parking_lot::Mutex;\nuse std::str::FromStr;\nuse std::{\n    borrow::Cow,\n    fmt::Write,\n    future::Future,\n    path::{Path, PathBuf},\n    sync::Arc,\n};\nuse task::{ShellKind, TaskTemplate, TaskTemplates, VariableName};\nuse util::{ResultExt, maybe};\n\npub(crate) fn semantic_token_rules() -> SemanticTokenRules {\n    let content = grammars::get_file(\"python/semantic_token_rules.json\")\n        .expect(\"missing python/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 python semantic_token_rules.json\")\n}\n\n#[derive(Debug, Serialize, Deserialize)]\npub(crate) struct PythonToolchainData {\n    #[serde(flatten)]\n    environment: PythonEnvironment,\n    #[serde(skip_serializing_if = \"Option::is_none\")]\n    activation_scripts: Option<HashMap<ShellKind, PathBuf>>,\n}\n\npub(crate) struct PyprojectTomlManifestProvider;\n\nimpl ManifestProvider for PyprojectTomlManifestProvider {\n    fn name(&self) -> ManifestName {\n        SharedString::new_static(\"pyproject.toml\").into()\n    }\n\n    fn search(","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/languages/src/python.rs#L42-L78","documentation":"Panics when the Python rules JSONC text fails to parse into SemanticTokenRules. Because file and type are versioned together, failure means structural drift between the vendored JSON and the Rust type (e.g., renamed fields), which is a developer error caught at first use of Python semantic tokens.","triggerScenarios":"Thrown at crates/languages/src/python.rs:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a deserialization test for python/semantic_token_rules.json to surface the serde error","Re-sync the JSON file with the SemanticTokenRules type definition","Log and use default rules instead of panicking on parse failure"],"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-14T00:17:10.932Z"}