{"record":{"id":"d081a87818b8db95","repo":"googleapis/mcp-toolbox","slug":"path-q-is-not-a-directory","errorCode":null,"errorMessage":"path %q is not a directory","messagePattern":"path %q is not a directory","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/internal/config.go","lineNumber":542,"sourceCode":"\tif len(configs) > 1 {\n\t\tmergedFile, err := mergeConfigs(configs...)\n\t\tif err != nil {\n\t\t\treturn Config{}, fmt.Errorf(\"unable to merge config files: %w\", err)\n\t\t}\n\t\treturn mergedFile, nil\n\t}\n\treturn configs[0], nil\n}\n\n// GetPathsFromConfigFolder loads all YAML files from a directory and merges them\nfunc GetPathsFromConfigFolder(ctx context.Context, folderPath string) ([]string, error) {\n\t// Check if directory exists\n\tinfo, err := os.Stat(folderPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to access config folder at %q: %w\", folderPath, err)\n\t}\n\tif !info.IsDir() {\n\t\treturn nil, fmt.Errorf(\"path %q is not a directory\", folderPath)\n\t}\n\n\t// Find all YAML files in the directory\n\tpattern := filepath.Join(folderPath, \"*.yaml\")\n\tyamlFiles, err := filepath.Glob(pattern)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error finding YAML files in %q: %w\", folderPath, err)\n\t}\n\n\t// Also find .yml files\n\tymlPattern := filepath.Join(folderPath, \"*.yml\")\n\tymlFiles, err := filepath.Glob(ymlPattern)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error finding YML files in %q: %w\", folderPath, err)\n\t}\n\n\t// Combine both file lists\n\tallFiles := append(yamlFiles, ymlFiles...)","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/cmd/internal/config.go#L524-L560","documentation":"After confirming the path exists, GetPathsFromConfigFolder requires it to be a directory. If info.IsDir() is false — i.e. the user passed a file path as a config folder — this error is thrown.","triggerScenarios":"Calling GetPathsFromConfigFolder with a path that points to a regular file (or symlink to a file) instead of a directory, e.g. passing --config-folder /path/to/config.yaml.","commonSituations":"Confusing --config-folder with --config-file and passing a YAML file path; a symlink pointing at a file instead of a directory.","solutions":["Pass a directory containing *.yaml files to --config-folder","If you meant a single file, use --config-file instead","Fix symlinks that resolve to files rather than directories"],"exampleFix":"// before\ntoolbox --config-folder ./config.yaml\n// after\ntoolbox --config-folder ./configs   # directory with *.yaml files","handlingStrategy":"validation","validationCode":"info, err := os.Stat(folder)\nif err == nil && !info.IsDir() {\n  return fmt.Errorf(\"%q is a file; use --config-file instead\", folder)\n}","typeGuard":null,"tryCatchPattern":"paths, err := GetPathsFromConfigFolder(ctx, folder)\nif err != nil {\n  if strings.Contains(err.Error(), \"is not a directory\") {\n    // caller passed a file; switch to LoadConfig with the file\n  }\n  return err\n}","preventionTips":["Distinguish --config-folder (directory) from --config-file (file) usage","Verify with os.Stat().IsDir() before passing a folder","Avoid symlinks that resolve to files when a directory is expected"],"tags":["filesystem","config-loading","argument-mismatch"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}