googleapis/mcp-toolbox · error

directory %q cannot be resolved: %w

Error message

directory %q cannot be resolved: %w

What it means

Wrap of a ResolveSymlinks failure on the configured directory during the second, symlink-aware containment pass in ResolveWithinDir: the real path of destination_dir could not be resolved (e.g. a broken symlink in the chain or an OS error).

Source

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

	}
	if filepath.IsAbs(rel) {
		return "", fmt.Errorf("path %q must be relative", rel)
	}

	cleanDest := filepath.Clean(filepath.Join(cleanDir, rel))
	out, err := escapes(cleanDir, cleanDest)
	if err != nil {
		return "", fmt.Errorf("path %q cannot be resolved within %q: %w", rel, cleanDir, err)
	}
	if out {
		return "", fmt.Errorf("path %q escapes configured directory %q", rel, cleanDir)
	}

	// Repeat the check against the real targets. A symlink under cleanDir can
	// point anywhere, so the name-level check above proves nothing on its own.
	resolvedDir, err := ResolveSymlinks(cleanDir)
	if err != nil {
		return "", fmt.Errorf("directory %q cannot be resolved: %w", cleanDir, err)
	}
	resolvedDest, err := ResolveSymlinks(cleanDest)
	if err != nil {
		return "", fmt.Errorf("path %q cannot be resolved: %w", rel, err)
	}
	out, err = escapes(resolvedDir, resolvedDest)
	if err != nil {
		return "", fmt.Errorf("path %q cannot be resolved within %q: %w", rel, cleanDir, err)
	}
	if out {
		return "", fmt.Errorf("path %q resolves through a symbolic link to a target outside configured directory %q", rel, cleanDir)
	}
	return cleanDest, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Repair or remove broken symlinks inside destination_dir
  2. Point destination_dir at a real directory that resolves without error
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:148 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/f01a54e91bbee3fb. Report an issue: GitHub.