zed-industries/zed · error

failed to parse go semantic_token_rules.json

Error message

failed to parse go semantic_token_rules.json

What it means

Panics when the Go rules JSONC text fails to deserialize into SemanticTokenRules. The file and the Rust type are vendored in lockstep, so a parse error means schema drift — the JSON's shape no longer matches SemanticTokenRules — introduced by an edit to either side.

Source

Thrown at crates/languages/src/go.rs:40

    future::Future,
    ops::Range,
    path::{Path, PathBuf},
    process::Output,
    str,
    sync::{
        Arc, LazyLock,
        atomic::{AtomicBool, Ordering::SeqCst},
    },
};
use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
use util::{ResultExt, fs::remove_matching, maybe, merge_json_value_into};

pub(crate) fn semantic_token_rules() -> SemanticTokenRules {
    let content = grammars::get_file("go/semantic_token_rules.json")
        .expect("missing go/semantic_token_rules.json");
    let json = std::str::from_utf8(&content.data).expect("invalid utf-8 in semantic_token_rules");
    settings::parse_json_with_comments::<SemanticTokenRules>(json)
        .expect("failed to parse go semantic_token_rules.json")
}

fn server_binary_arguments() -> Vec<OsString> {
    vec!["-mode=stdio".into()]
}

#[derive(Copy, Clone)]
pub struct GoLspAdapter;

impl GoLspAdapter {
    const SERVER_NAME: LanguageServerName = LanguageServerName::new_static("gopls");
}

static VERSION_REGEX: LazyLock<Regex> =
    LazyLock::new(|| Regex::new(r"\d+\.\d+\.\d+").expect("Failed to create VERSION_REGEX"));

static GO_ESCAPE_SUBTEST_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
    Regex::new(r#"[.*+?^${}()|\[\]\\"']"#).expect("Failed to create GO_ESCAPE_SUBTEST_NAME_REGEX")

View on GitHub (pinned to f4178619ac)

Solutions

  1. Reproduce deserialization in a unit test to expose the serde mismatch and fix the file or type
  2. Add CI validation that parses every vendored semantic_token_rules.json against its target type
  3. Fall back to default rules with a logged warning instead of panicking
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/languages/src/go.rs:40 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/d3cf48af57b2174c. Report an issue: GitHub.