{"record":{"id":"c2bad2b37efdaee2","repo":"stanfordnlp/CoreNLP","slug":"no-matching-files-basedir-filepattern","errorCode":null,"errorMessage":"No matching files: {baseDir}\t{filePattern}","messagePattern":"No matching files: (.+?)\t(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java","lineNumber":894,"sourceCode":"\n  public ObjectBank<List<IN>> makeObjectBankFromFiles(String baseDir, String filePattern,\n                                                      DocumentReaderAndWriter<IN> readerAndWriter) {\n\n    File path = new File(baseDir);\n    FileFilter filter = new RegExFileFilter(Pattern.compile(filePattern));\n    File[] origFiles = path.listFiles(filter);\n    Collection<File> files = new ArrayList<>();\n    for (File file : origFiles) {\n      if (file.isFile()) {\n        if (flags.announceObjectBankEntries) {\n          log.info(\"Getting data from \" + file + \" (\" + flags.inputEncoding + \" encoding)\");\n        }\n        files.add(file);\n      }\n    }\n\n    if (files.isEmpty()) {\n      throw new RuntimeException(\"No matching files: \" + baseDir + '\\t' + filePattern);\n    }\n    // return new ObjectBank<List<IN>>(new\n    // ResettableReaderIteratorFactory(files, flags.inputEncoding),\n    // readerAndWriter);\n    // TODO get rid of ObjectBankWrapper\n    return new ObjectBankWrapper<>(flags, new ObjectBank<>(new ResettableReaderIteratorFactory(files,\n            flags.inputEncoding), readerAndWriter), knownLCWords);\n  }\n\n  public ObjectBank<List<IN>> makeObjectBankFromFiles(Collection<File> files,\n                                                      DocumentReaderAndWriter<IN> readerAndWriter) {\n    if (files.isEmpty()) {\n      throw new RuntimeException(\"Attempt to make ObjectBank with empty file list\");\n    }\n    // return new ObjectBank<List<IN>>(new\n    // ResettableReaderIteratorFactory(files, flags.inputEncoding),\n    // readerAndWriter);\n    // TODO get rid of ObjectBankWrapper","sourceCodeStart":876,"sourceCodeEnd":912,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/ie/AbstractSequenceClassifier.java#L876-L912","documentation":"When building an ObjectBank from a base directory plus a file pattern, makeObjectBankFromString/IO-style scanning collects matching files; if none match, a RuntimeException with the baseDir and pattern is thrown so the caller knows their inputs are wrong rather than silently training/labeling on zero documents.","triggerScenarios":"Calling makeObjectBankFromString/../makeObjectBank with a baseDir that does not exist, is empty, or a filePattern that matches no files under it.","commonSituations":"Wrong data directory path (relative vs absolute, wrong working directory); overly restrictive extension pattern (e.g. '*.txt' vs '.txt' files); typo'd glob; data not copied to the deployment environment.","solutions":["Verify baseDir exists and contains files: new File(baseDir).isDirectory() and list contents","Test the filePattern matching (e.g. Files.walk + matches) before calling","Fix the pattern (e.g. use \"\\.txt$\" regex form if that is what the code expects)","Use an absolute path and confirm the process's working directory"],"exampleFix":"// before\nObjectBank<List<CoreLabel>> bank = classifier.makeObjectBankFromString(\"/wrong/dir\", \"*.txt\");\n// after\nFile dir = new File(\"/data/corpus\");\nif (!dir.isDirectory() || dir.listFiles().length == 0) throw new IllegalArgumentException(\"bad data dir\");\nObjectBank<List<CoreLabel>> bank = classifier.makeObjectBankFromString(\"/data/corpus\", \".txt\");","handlingStrategy":"validation","validationCode":"File dir = new File(baseDir);\nif (!dir.isDirectory()) throw new IllegalArgumentException(\"baseDir is not a directory: \" + baseDir);\nboolean any = false;\nfor (File f : dir.listFiles()) if (f.getName().matches(filePattern)) { any = true; break; }\nif (!any) throw new IllegalArgumentException(\"No files match pattern\");","typeGuard":null,"tryCatchPattern":"try { bank = classifier.makeObjectBankFromString(baseDir, pattern); }\ncatch (RuntimeException e) { if (e.getMessage().startsWith(\"No matching files\")) { e.printStackTrace(); } throw e; }","preventionTips":["Assert the data directory is non-empty before pipeline runs","Test the glob/regex against real filenames","Use absolute paths and log the working directory"],"tags":["io","file-pattern","empty-input"],"backgroundTag":"empty-result-set","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}