zed-industries/zed · error · anyhow::Error

Failed to parse semantic token rules from {}

Error message

Failed to parse semantic token rules from {}

What it means

Parse context in SemanticTokenRules::load(): the file was read but serde_json_lenient could not parse its contents into SemanticTokenRule entries. The underlying syntax error is wrapped by this message naming the file.

Source

Thrown at crates/settings_content/src/project.rs:292

#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema)]
#[serde(transparent)]
pub struct SemanticTokenRules {
    pub rules: Vec<SemanticTokenRule>,
}

impl SemanticTokenRules {
    pub const FILE_NAME: &'static str = "semantic_token_rules.json";

    pub fn load(file_path: &Path) -> anyhow::Result<Self> {
        let rules_content = std::fs::read(file_path).with_context(|| {
            anyhow::anyhow!(
                "Could not read semantic token rules from {}",
                file_path.display()
            )
        })?;

        serde_json_lenient::from_slice::<SemanticTokenRules>(&rules_content).with_context(|| {
            anyhow::anyhow!(
                "Failed to parse semantic token rules from {}",
                file_path.display()
            )
        })
    }
}

impl crate::merge_from::MergeFrom for SemanticTokenRules {
    fn merge_from(&mut self, other: &Self) {
        self.rules.splice(0..0, other.rules.iter().cloned());
    }
}

#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct SemanticTokenRule {
    pub token_type: Option<String>,
    #[serde(default)]

View on GitHub (pinned to f4178619ac)

Solutions

  1. Fix the JSON syntax and schema of semantic_token_rules.json
  2. Validate the file against the SemanticTokenRules schema
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/settings_content/src/project.rs:292 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/873cc0be895259b4. Report an issue: GitHub.