googleapis/mcp-toolbox · error
error finding YML files in %q: %w
Error message
error finding YML files in %q: %w
What it means
After globbing *.yaml, GetPathsFromConfigFolder separately globs *.yml files and wraps any Glob error the same way. As with the .yaml pass, filepath.Glob only errors on a malformed pattern, so this signals the folder path produced an invalid glob pattern, not an empty directory.
Source
Thrown at cmd/internal/config.go:556
if err != nil {
return nil, fmt.Errorf("unable to access config folder at %q: %w", folderPath, err)
}
if !info.IsDir() {
return nil, fmt.Errorf("path %q is not a directory", folderPath)
}
// Find all YAML files in the directory
pattern := filepath.Join(folderPath, "*.yaml")
yamlFiles, err := filepath.Glob(pattern)
if err != nil {
return nil, fmt.Errorf("error finding YAML files in %q: %w", folderPath, err)
}
// Also find .yml files
ymlPattern := filepath.Join(folderPath, "*.yml")
ymlFiles, err := filepath.Glob(ymlPattern)
if err != nil {
return nil, fmt.Errorf("error finding YML files in %q: %w", folderPath, err)
}
// Combine both file lists
allFiles := append(yamlFiles, ymlFiles...)
return allFiles, nil
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Escape or remove glob metacharacters in the config folder path (filepath.EvalSymlinks/Escape, rename the directory)
- Confirm the --prebuilt/--tools-file value points to a plain directory, since the code appends "*.yml" itself
- Test the pattern with filepath.Match in isolation to reproduce ErrBadPattern
- Fall back to os.ReadDir + suffix filtering if directory names contain metacharacters
Example fix
// before
paths, err := GetPathsFromConfigFolder(ctx, "/etc/toolbox/run[2]")
// after
clean := filepath.Escape("/etc/toolbox/run[2]")
paths, err := GetPathsFromConfigFolder(ctx, clean) Defensive patterns
Strategy: validation
Validate before calling
if badGlobPattern(filepath.Join(folderPath, "*.yml")) {
return fmt.Errorf("invalid path %q for yml glob", folderPath)
}
paths, err := GetPathsFromConfigFolder(ctx, folderPath) Type guard
func globPatternValid(pattern string) bool {
_, err := filepath.Match(pattern, "probe")
return !errors.Is(err, filepath.ErrBadPattern)
} Prevention
- Avoid brackets/brackets-and-wildcards in config folder names (e.g. CI dirs like build[1])
- Escape the path with filepath.Escape before passing it in
- Prefer os.ReadDir-style enumeration if directory names may contain metacharacters
When it happens
Trigger: GetPathsFromConfigFolder called with a folderPath such that filepath.Glob(filepath.Join(folderPath, "*.yml")) returns ErrBadPattern — e.g. path containing an unterminated '[' or trailing backslash escape on Windows.
Common situations: Config directory names containing brackets or wildcard characters (common in CI artifact paths like 'build[1]'), or misconfigured flag/env values that embed a partial glob into the directory path.
Related errors
- error finding YAML files in %q: %w
- unable to read config file at %q: %w
- unable to access config folder at %q: %w
- path %q is not a directory
- failed to stat file: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/522b5fb61ca074d4.
Report an issue: GitHub.