JetBrains/intellij-community · error · ConfigurationException

Enter a module name

Error message

Enter a module name

What it means

Thrown by ModuleNameLocationComponent.validateModulePaths() when the module name field is empty. A module cannot be created without a name (it is the key used by ModuleManager), so the wizard demands a name before proceeding.

Source

Thrown at java/idea-ui/src/com/intellij/ide/projectWizard/ModuleNameLocationComponent.java:358

      module = modifiableModel.findModuleByName(moduleName);
    }
    else {
      module = ModuleManager.getInstance(project).findModuleByName(moduleName);
    }
    if (module != null) {
      throw new ConfigurationException(
        JavaUiBundle.message("module.name.location.dialog.message.module.already.exist.in.project", moduleName));
    }
  }

  private boolean validateModulePaths() throws ConfigurationException {
    String moduleName = getModuleName();
    String moduleFileDirectory = myModuleFileLocation.getText();
    if (moduleFileDirectory.isEmpty()) {
      throw new ConfigurationException(JavaUiBundle.message("module.name.location.dialog.message.enter.module.file.location"));
    }
    if (moduleName.isEmpty()) {
      throw new ConfigurationException(JavaUiBundle.message("module.name.location.dialog.message.enter.module.name"));
    }

    if (!ProjectWizardUtil.createDirectoryIfNotExists(JavaUiBundle.message("directory.module.file"), moduleFileDirectory,
                                                      myImlLocationChangedByUser)) {
      return false;
    }
    if (!ProjectWizardUtil.createDirectoryIfNotExists(JavaUiBundle.message("directory.module.content.root"), myModuleContentRoot.getText(),
                                                      myContentRootChangedByUser)) {
      return false;
    }

    File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION);
    if (moduleFile.exists()) {
      int answer = MessageDialogBuilder.yesNo(IdeBundle.message("title.file.already.exists"),
                                              CoreBundle.message("prompt.overwrite.project.file", moduleFile.getAbsolutePath(),
                                                                 IdeCoreBundle.message("project.new.wizard.module.identification"))).show();
      if (answer != Messages.YES) {
        return false;

View on GitHub (pinned to be881553f2)

Solutions

  1. Enter a non-empty module name in the wizard's name field
  2. In plugin code, always call setModuleName(uniqueName) before invoking validate()
  3. Trim user input in custom wrappers so whitespace-only names are treated as empty early

Example fix

// before
component.setModuleFilePath(path);
// name field empty
component.validate(); // ConfigurationException: Enter a module name

// after
component.setModuleName("payment-service");
component.setModuleFilePath(path + "/payment-service/payment-service.iml");
component.validate();
Defensive patterns

Strategy: validation

Validate before calling

if (component.getModuleName() == null || component.getModuleName().trim().isEmpty()) {
  // set a default name like 'untitledN' before calling validate()
}

Prevention

When it happens

Trigger: Calling validate()/validateModulePaths() when getModuleName() returns the empty string — the name field was cleared or a programmatic caller never set a name.

Common situations: User clears the auto-generated name in the New Module dialog; automation drives the wizard without seeding the name field; trailing-whitespace-only name passes a non-null check but fails the empty check after trimming.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/2bca4a55b5cdb44a. Report an issue: GitHub.