{"record":{"id":"e0382ad784cba832","repo":"JetBrains/intellij-community","slug":"0-is-not-a-valid-package-name","errorCode":null,"errorMessage":"{0} is not a valid package name","messagePattern":"(.+?) is not a valid package name","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java","lineNumber":80,"sourceCode":"      @Override\n      public String getValue() {\n        return myField.getText();\n      }\n\n      @Override\n      public Map<String, String> getValues() {\n        HashMap<String, String> map = new HashMap<>(2);\n        map.put(getId(), getValue());\n        map.put(\"IJ_BASE_PACKAGE_DIR\", getValue().replace('.', '/'));\n        map.put(\"IJ_BASE_PACKAGE_PREFIX\", StringUtil.isEmpty(getValue()) ? \"\" : getValue() + \".\");\n        return map;\n      }\n\n      @Override\n      public boolean validate() throws ConfigurationException {\n        String value = getValue();\n        if (!StringUtil.isEmpty(value) && !PsiNameHelperImpl.getInstance().isQualifiedName(value)) {\n          throw new ConfigurationException(JavaBundle.message(\"base.package.project.wizard.error.x.not.valid.package\", value));\n        }\n        PropertiesComponent.getInstance().setValue(IJ_BASE_PACKAGE, value);\n        return true;\n      }\n    };\n  }\n\n  @Override\n  public String detectParameterValue(Project project) {\n    PsiPackage root = JavaPsiFacade.getInstance(project).findPackage(\"\");\n    if (root == null) return null;\n    String name = getBasePackage(root, GlobalSearchScope.projectScope(project)).getQualifiedName();\n    return StringUtil.isEmpty(name) ? null : name;\n  }\n\n  private static PsiPackage getBasePackage(PsiPackage pack, GlobalSearchScope scope) {\n    List<PsiPackage> subPackages = ContainerUtil.filter(pack.getSubPackages(scope), PACKAGE_CONDITION);\n    return subPackages.size() == 1 ? getBasePackage(subPackages.get(0), scope) : pack;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/java-impl/src/com/intellij/openapi/module/BasePackageParameterFactory.java#L62-L98","documentation":"Thrown by BasePackageParameterFactory.validate() in the new-project wizard when the 'Base package' field contains a string that is not a valid Java qualified package name. Validation uses PsiNameHelperImpl.isQualifiedName(), which enforces Java identifier segments separated by dots. The error is a ConfigurationException shown directly in the wizard UI.","triggerScenarios":"Entering values like 'com.example.mypackage.' (trailing dot), 'com.1example' (segment starting with a digit), 'my-package' (hyphen), 'com..example' (empty segment), or whitespace anywhere in the base package field of a Java project wizard, then pressing Next/Finish.","commonSituations":"Copy-pasting a package path from a file system directory or Maven groupId that is not a legal Java package; pasting with a trailing newline/space; templates or automation scripts that inject an empty or malformed base package; users assuming hyphens are allowed because the folder name allows them.","solutions":["Correct the value in the 'Base package' field to dot-separated Java identifiers, e.g. com.example.myapp (segments must start with a letter, $ or _ and contain only letters, digits, $ or _).","Remove leading/trailing dots, double dots, hyphens and whitespace from the field.","If the value looks correct, check for invisible characters (non-breaking space, trailing newline) pasted from a browser or chat message.","Leave the field empty if the template allows a default root package."],"exampleFix":"// before (wizard field value)\ncom.my-app.\n// after\ncom.myapp","handlingStrategy":"validation","validationCode":"PsiNameHelper helper = PsiNameHelper.getInstance(project);\nString value = basePackageField.getText().trim();\nif (!value.isEmpty() && !helper.isQualifiedName(value)) {\n  // show inline error instead of letting validate() throw\n  report(\"Not a valid Java package name: \" + value);\n}","typeGuard":null,"tryCatchPattern":"try { parameter.validate(); } catch (ConfigurationException e) { /* show e.getMessage() in wizard, keep dialog open */ }","preventionTips":["Validate package names with PsiNameHelper.isQualifiedName() as the user types (document listener), not only on Next.","Sanitize pasted text: trim, collapse whitespace, reject hyphens and empty segments early.","Provide a sensible default base package (derived from project name) so users rarely type one manually."],"tags":["java","package-name","project-wizard","validation"],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}