googleapis/mcp-toolbox · error

cannot resolve path %q: no existing ancestor

Error message

cannot resolve path %q: no existing ancestor

What it means

ResolveSymlinks walked all the way up without finding any existing ancestor directory (the walk reached the root), so there is no resolvable base to anchor the path — effectively the path's directories do not exist yet and cannot be verified.

Source

Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:94

	resolved, err := filepath.EvalSymlinks(path)
	if err == nil {
		return resolved, nil
	}
	if !errors.Is(err, fs.ErrNotExist) {
		return "", fmt.Errorf("cannot resolve path %q: %w", path, err)
	}

	// Walk up to the deepest ancestor that does resolve, remembering the
	// components we stepped over so they can be reattached to it.
	var missing []string
	cur := path
	for {
		if fi, lerr := os.Lstat(cur); lerr == nil && fi.Mode()&fs.ModeSymlink != 0 {
			return "", fmt.Errorf("path %q traverses unresolvable symbolic link %q", path, cur)
		}
		parent := filepath.Dir(cur)
		if parent == cur {
			return "", fmt.Errorf("cannot resolve path %q: no existing ancestor", path)
		}
		missing = append([]string{filepath.Base(cur)}, missing...)
		cur = parent

		resolvedParent, perr := filepath.EvalSymlinks(cur)
		if perr == nil {
			return filepath.Join(append([]string{resolvedParent}, missing...)...), nil
		}
		if !errors.Is(perr, fs.ErrNotExist) {
			return "", fmt.Errorf("cannot resolve path %q: %w", path, perr)
		}
	}
}

// escapes reports whether target lies outside dir. Both are expected to be
// cleaned absolute paths.
func escapes(dir, target string) (bool, error) {
	within, err := filepath.Rel(dir, target)

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Create the parent directories before running the tool
  2. Check the path for typos in early components
  3. Verify the mount/root actually exists
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:94 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/fb0df6985a3a6580. Report an issue: GitHub.