zed-industries/zed · error

Invalid glob

Error message

Invalid glob: {err}

What it means

Raised in search_paths when PathMatcher::new rejects the model-supplied glob (with the empty glob substituted by `*`) as invalid syntax for the project's path style. The glob parsing error {err} names the fault; no paths can be searched until a valid glob is supplied.

Solutions

  1. Correct the glob syntax (common issues: unbalanced brackets, invalid '**' placement)
  2. Retry with a simpler pattern like '*.rs' or a plain substring path
  3. If the model intended everything, an empty glob is auto-treated as '*'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/agent/src/tools/find_path_tool.rs:192 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at crates/agent/src/tools/find_path_tool.rs:192

                offset: input.offset,
                current_matches_page: paginated_matches.to_vec(),
                all_matches_len: matches.len(),
            })
        })
    }
}

fn search_paths(glob: &str, project: Entity<Project>, cx: &mut App) -> Task<Result<Vec<PathBuf>>> {
    let path_style = project.read(cx).path_style(cx);
    let path_matcher = match PathMatcher::new(
        [
            // Sometimes models try to search for "". In this case, return all paths in the project.
            if glob.is_empty() { "*" } else { glob },
        ],
        path_style,
    ) {
        Ok(matcher) => matcher,
        Err(err) => return Task::ready(Err(anyhow!("Invalid glob: {err}"))),
    };
    let snapshots: Vec<_> = project
        .read(cx)
        .worktrees(cx)
        .map(|worktree| worktree.read(cx).snapshot())
        .collect();

    cx.background_spawn(async move {
        let mut results = Vec::new();
        for snapshot in snapshots {
            for entry in snapshot.entries(false, 0) {
                if path_matcher.is_match(&snapshot.root_name().join(&entry.path)) {
                    results.push(snapshot.absolutize(&entry.path));
                }
            }
        }

        Ok(results)

View on GitHub (pinned to f4178619ac)