JetBrains/intellij-community · warning · ConfigurationException
''{0}'' is invalid destination package name
Error message
''{0}'' is invalid destination package name What it means
Thrown by MoveClassesOrPackagesDialog.canRun() (MoveClassesOrPackagesDialog.java:551) when moving to a package and the target package field is non-empty but fails PsiNameHelper.isQualifiedName. It validates only the grammar of the destination package name ('a.b.c' of identifiers); an empty field is allowed (means the default/root package). Same dialog-validation contract: ConfigurationException is shown and the move dialog stays open.
Source
Thrown at java/java-impl-refactorings/src/com/intellij/refactoring/move/moveClassesOrPackages/MoveClassesOrPackagesDialog.java:551
initialRoots.add(sourceRootForFile);
}
}
else if (element instanceof PsiDirectoryContainer) {
collectSourceRoots(((PsiDirectoryContainer)element).getDirectories(), fileIndex, initialRoots);
}
}
}
protected final boolean isSearchInComments() {
return myCbSearchInComments.isSelected();
}
@Override
protected void canRun() throws ConfigurationException {
if (isMoveToPackage()) {
String name = getTargetPackage().trim();
if (!name.isEmpty() && !PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(name)) {
throw new ConfigurationException(JavaBundle.message("move.classes.invalid.destination.package.name.message", name));
}
}
else {
if (findTargetClass() == null) {
throw new ConfigurationException(
JavaBundle.message("move.classes.destination.class.not.found.message"));
}
final String validationError = verifyInnerClassDestination();
if (validationError != null) throw new ConfigurationException(validationError);
}
}
@Override
protected void validateButtons() {
validateButtonsAsync(ModalityState.stateForComponent(myMainPanel));
}
private @Nullable PsiClass findTargetClass() {View on GitHub (pinned to be881553f2)
Solutions
- Correct the destination package field to dot-separated identifiers, or clear it for the default package.
- Use the package chooser (...) rather than typing.
- Pre-check: PsiNameHelper.getInstance(project).isQualifiedName(name.trim()) for any non-empty typed name.
Example fix
// before // target package: com.acme..util -> ConfigurationException // after // target package: com.acme.util
Defensive patterns
Strategy: validation
Validate before calling
String target = getTargetPackage().trim();
if (!target.isEmpty() && !PsiNameHelper.getInstance(project).isQualifiedName(target)) {
// block before OK; use the package chooser for correctness
} Prevention
- Prefer the package tree picker over typing.
- Trim input; reject doubled dots ('..') and trailing dots early in custom UIs.
When it happens
Trigger: Refactoring | Move Class to Package (F6) with the target package text field containing 'com..acme', 'com acme', '1com', or a keyword segment. Only fires when moving to a package, not to an inner class.
Common situations: Hand-typing a new package name with typos, trailing/doubled dots, spaces, or pasting a package name that carries an invisible whitespace character.
Related errors
- Invalid package name: {0}
- ''{0}'' is invalid parameter class package name
- replace.constructor.builder.error.invalid.builder.package.na
- Nothing found to extract
- ''{0}'' is invalid extracted class name
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/4776113996753533.
Report an issue: GitHub.