jenkinsci/jenkins · error · IllegalArgumentException
Invalid view name:
Error message
Invalid view name:
What it means
`CreateViewCommand.run()` calls `View.createViewFromXML(viewName, stdin)` inside a try; if it throws a `hudson.model.Failure` (view-name validation failure — illegal characters, reserved name, etc.), the catch rethrows it as IllegalArgumentException 'Invalid view name: <Failure.message>'. The Failure is the model-level validation result for the view name.
Source
Thrown at core/src/main/java/hudson/cli/CreateViewCommand.java:60
@Override
public String getShortDescription() {
return Messages.CreateViewCommand_ShortDescription();
}
@Override
protected int run() throws Exception {
final Jenkins jenkins = Jenkins.get();
jenkins.checkPermission(View.CREATE);
View newView;
try {
newView = View.createViewFromXML(viewName, stdin);
} catch (Failure ex) {
throw new IllegalArgumentException("Invalid view name: " + ex.getMessage());
}
final String newName = newView.getViewName();
if (jenkins.getView(newName) != null) {
throw new IllegalStateException("View '" + newName + "' already exists");
}
jenkins.addView(newView);
return 0;
}
}
View on GitHub (pinned to 2e228ff40b)
Solutions
- Use a valid view name: alphanumeric with safe separators, no slashes or reserved tokens.
- Pass the name via the argument to override a bad name embedded in the XML, or fix the XML.
- Check Jenkins' view-name rules (similar to job-name rules: no '/', no leading '.', etc.) before creating.
Example fix
// before: // java -jar jenkins-cli.jar create-view 'my/view' < view.xml // -> IllegalArgumentException: Invalid view name: ... (slash not allowed) // // after: use a permitted name // java -jar jenkins-cli.jar create-view myView < view.xml
Defensive patterns
Strategy: validation
Validate before calling
// Validate the view name the same way View.createViewFromXML does before creating
try {
Jenkins.checkGoodName(viewName); // reuse Jenkins' name rules as a first guard
} catch (Failure f) {
throw new IllegalArgumentException("Invalid view name: " + f.getMessage());
} Prevention
- Restrict view names to alphanumeric characters and safe separators; avoid '/', leading '.', and reserved tokens.
- Pass the name via the argument rather than embedding an invalid one in the XML.
When it happens
Trigger: Running `java -jar jenkins-cli.jar create-view <name> < view.xml` where <name> (or the name in the XML) fails View's name validation — e.g. contains characters not allowed in view names, is empty, or collides with a reserved identifier.
Common situations: Special characters, spaces, or slashes in the view name; very long names; names conflicting with built-in views.
Related errors
- View ' already exists
- Job ' already exists
- Unknown ItemGroup
- Can't create job from CLI in
- Node ' already exists
AI-assisted analysis of jenkinsci/jenkins@2e228ff40b (2026-08-14).
Data as JSON: /api/errors/a09fb7b0d3af507d.
Report an issue: GitHub.