{"record":{"id":"36dba98b157b40cf","repo":"JetBrains/intellij-community","slug":"module-name-has-no-content-roots-and-will-not-be","errorCode":null,"errorMessage":"Module {name} has no content roots and will not be created.","messagePattern":"Module (.+?) has no content roots and will not be created\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"java/idea-ui/src/com/intellij/ide/util/importProject/ModuleDescriptor.java","lineNumber":173,"sourceCode":"    return builder.toString();\n  }\n\n  public void clearModuleDependencies() {\n    myDependencies.clear();\n  }\n\n  public void clearLibraryFiles() {\n    myLibraryFiles.clear();\n  }\n\n  public @NotNull String computeModuleFilePath() throws InvalidDataException {\n    final String name = getName();\n    final Set<File> contentRoots = getContentRoots();\n    if (!contentRoots.isEmpty()) {\n      return contentRoots.iterator().next().getPath() + File.separator + name + ModuleFileType.DOT_DEFAULT_EXTENSION;\n    }\n    else {\n      throw new InvalidDataException(\"Module \" + name + \" has no content roots and will not be created.\");\n    }\n  }\n}\n","sourceCodeStart":155,"sourceCodeEnd":177,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/idea-ui/src/com/intellij/ide/util/importProject/ModuleDescriptor.java#L155-L177","documentation":"Thrown by ModuleDescriptor.computeModuleFilePath() (InvalidDataException) when a module descriptor produced by project import has no content roots. The .iml path is derived from the first content root plus the module name; with zero content roots there is no basis for a path, so the importer refuses to fabricate a module file location.","triggerScenarios":"Building ModuleDescriptor objects during import-from-sources and calling computeModuleFilePath() on a descriptor whose getContentRoots() set is empty — e.g. addContentRoot() was never called or the detected roots list was empty.","commonSituations":"Importing a directory layout where a module's patterns match no folders; a third-party import plugin creates descriptors from a config that lists no roots; refactor leaves an intermediate descriptor unpopulated before path computation.","solutions":["Add at least one content root to the descriptor: descriptor.addContentRoot(VfsUtilCore.pathToUrl(dir)) before computing the path","If importing, re-run import with correct source/root selection so the detector finds folders for every module","Skip modules with no roots instead of materializing them (they would be useless in the model)"],"exampleFix":"// before\nModuleDescriptor desc = new ModuleDescriptor(name, javaModuleType, contentEntryProvider);\ndesc.computeModuleFilePath(); // InvalidDataException: no content roots\n\n// after\nModuleDescriptor desc = new ModuleDescriptor(name, javaModuleType, contentEntryProvider);\ndesc.addContentRoot(new File(baseDir, name));\ndesc.computeModuleFilePath(); // <root>/<name>/<name>.iml","handlingStrategy":"validation","validationCode":"if (descriptor.getContentRoots().isEmpty()) {\n  descriptor.addContentRoot(moduleBaseDir); // or skip this descriptor entirely\n}\nString imlPath = descriptor.computeModuleFilePath();","typeGuard":null,"tryCatchPattern":"try {\n  paths.add(descriptor.computeModuleFilePath());\n} catch (InvalidDataException e) {\n  // log and skip the root-less module; do not abort the whole import\n}","preventionTips":["Always addContentRoot(...) right after constructing a ModuleDescriptor","Validate import descriptors in bulk before computing paths so one bad module does not stop the import"],"tags":["module","import","content-root","intellij"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}