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.
Solutions
- Fix the JSON syntax and schema of semantic_token_rules.json
- 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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/873cc0be895259b4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/settings_content/src/project.rs:373
/// Timeout in milliseconds for automatically dismissing language server notifications.
/// Set to 0 to disable auto-dismiss.
///
/// Default: 5000
pub dismiss_timeout_ms: Option<u64>,
}
/// Custom rules for rendering LSP semantic tokens.
#[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_to_string(file_path).with_context(|| {
anyhow::anyhow!(
"Could not read semantic token rules from {}",
file_path.display()
)
})?;
Self::parse(&rules_content).with_context(|| {
anyhow::anyhow!(
"Failed to parse semantic token rules from {}",
file_path.display()
)
})
}
pub fn parse(file_content: &str) -> anyhow::Result<Self> {
serde_json_lenient::from_str::<SemanticTokenRules>(file_content)
.context("failed to parse semantic token rules")
}View on GitHub (pinned to 916fc2b8cb)