{"record":{"id":"8552f4e3d1d9242d","repo":"yamadashy/repomix","slug":"failed-to-filter-files-in-directory-rootdir-re","errorCode":null,"errorMessage":"Failed to filter files in directory ${rootDir}. Reason: ${error.message}","messagePattern":"Failed to filter files in directory (.+?)\\. Reason: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/file/fileSearch.ts","lineNumber":348,"sourceCode":"\n    logger.debug(\n      `[result] Total files: ${confinedFilePaths.length}, empty directories: ${confinedEmptyDirPaths.length}`,\n    );\n    logger.trace(`Filtered ${confinedFilePaths.length} files`);\n\n    return {\n      filePaths: sortPaths(confinedFilePaths),\n      emptyDirPaths: sortPaths(confinedEmptyDirPaths),\n    };\n  } catch (error: unknown) {\n    // Re-throw PermissionError as is\n    if (error instanceof PermissionError) {\n      throw error;\n    }\n\n    if (error instanceof Error) {\n      logger.error('Error filtering files:', error.message);\n      throw new Error(`Failed to filter files in directory ${rootDir}. Reason: ${error.message}`);\n    }\n\n    logger.error('An unexpected error occurred:', error);\n    throw new Error('An unexpected error occurred while filtering files.');\n  }\n};\n\nexport const parseIgnoreContent = (content: string): string[] => {\n  if (!content) return [];\n\n  return content.split('\\n').reduce<string[]>((acc, line) => {\n    const trimmedLine = line.trim();\n    if (trimmedLine && !trimmedLine.startsWith('#')) {\n      acc.push(trimmedLine);\n    }\n    return acc;\n  }, []);\n};","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/yamadashy/repomix/blob/f465ad909315a22120636baf03fa5e28701a50cb/src/core/file/fileSearch.ts#L330-L366","documentation":"Generic wrapper error from searchFiles: any non-PermissionError Error thrown while filtering files (globby scan, filtering, etc.) is caught, logged, and rethrown with the root directory and original message attached. PermissionError instances are rethrown unchanged.","triggerScenarios":"Any Error thrown inside searchFiles' try block other than PermissionError — e.g. malformed file patterns, globby internal failures, or filesystem errors with codes other than EPERM/EACCES.","commonSituations":"Invalid glob patterns in repomix config, unusual filesystem errors (EMFILE too many open files, EIO), or plugin/config issues producing bad include patterns.","solutions":["Read the 'Reason:' suffix in the message — it contains the underlying error — and fix that root cause.","Check your repomix.json include/ignore glob patterns for typos or invalid syntax.","If the reason is EMFILE, raise the file descriptor limit (ulimit -n) or reduce the size of the scanned tree.","Retry after fixing; if the underlying cause is a permission issue, address it per the PermissionError guidance."],"exampleFix":"// before: invalid include pattern in repomix.config.json\n\"include\": [\"src/[!\"]\n\n// after\n\"include\": [\"src/**/*\"]","handlingStrategy":"try-catch","validationCode":"// Pre-validate glob patterns before packing\nconst patterns = config.include.concat(config.ignore);\nfor (const p of patterns) {\n  if (p.includes('[') && !/^\\[!?.*\\]$/.test(p.split('/').find(s => s.startsWith('[')) ?? '')) {\n    throw new Error(`Suspicious glob pattern: ${p}`);\n  }\n}","typeGuard":"const isPermissionError = (e: unknown): e is Error & { name: 'PermissionError' } =>\n  e instanceof Error && e.name === 'PermissionError';","tryCatchPattern":"try {\n  await repomix.pack({ input: { rootDir } });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to filter files in directory')) {\n    console.error('Underlying cause:', e.message.split('Reason: ')[1]);\n  } else throw e;\n}","preventionTips":["Validate include/ignore glob patterns (e.g. with minimatch) before running.","Watch file descriptor limits when packing very large trees (ulimit -n).","Keep globby and filesystem-related dependencies up to date.","Read the 'Reason:' part of the message — it names the true root cause."],"tags":["filesystem","globby","error-wrapping"],"backgroundTag":"file-scan-failed","analyzedSha":"f465ad909315a22120636baf03fa5e28701a50cb","analyzedAt":"2026-08-29T01:27:42.024Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}