zed-industries/zed · error

Failed to parse snippet file at {snippet_path:?}

Error message

Failed to parse snippet file at {snippet_path:?}

What it means

During extension testing, a snippet file listed in the manifest could not be parsed: serde_json_lenient::from_slice::<VsSnippetsFile> on the file's bytes failed. The snippet file exists and was loaded, but its top-level structure is not a valid VS Code-style snippets file; {snippet_path} identifies the file.

Source

Thrown at crates/extension_cli/src/main.rs:577

            let entry = entry?;
            let file_path = entry.path();

            let Some(file_name) = file_path.file_name().and_then(|name| name.to_str()) else {
                continue;
            };

            match file_name {
                LanguageConfig::FILE_NAME => {
                    // Loaded above
                }
                SemanticTokenRules::FILE_NAME => {
                    let _token_rules = SemanticTokenRules::load(&file_path)?;
                }
                TaskTemplates::FILE_NAME => {
                    let task_file_content = std::fs::read(&file_path).with_context(|| {
                        anyhow!(
                            "Failed to read tasks file at {path}",
                            path = file_path.display()
                        )
                    })?;
                    let _task_templates =
                        serde_json_lenient::from_slice::<TaskTemplates>(&task_file_content)
                            .with_context(|| {
                                anyhow!(
                                    "Failed to parse tasks file at {path}",
                                    path = file_path.display()
                                )
                            })?;
                }
                _ => {
                    if let Ok(_query) = file_name.parse::<QueryFile>() {
                        let grammar = grammar.with_context(|| {
                            format! {
                                "language {} provides query {} but no grammar",
                                config.name,
                                file_path.display()

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Fix the JSON structure — a VS snippets file is an object keyed by snippet name with prefix/body/description fields
  2. Validate JSON syntax separately (e.g. with a JSON linter) to rule out trailing commas or comments if strict parsing is used
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/extension_cli/src/main.rs:552 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


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