Repository navigation
Description
Summary
Opening the "New Spring Starter Project" wizard sometimes pre-fills the Name and Artifact fields with the literal string -1 instead of a sensible non-empty default such as demo.
This is reproducible without any UI interaction by instantiating NewSpringBootWizardModel directly.
Root cause
Two independent gaps combine to produce this:
1. NewSpringBootWizardModel#discoverOptions only null-checks the default value fetched from the Initializr metadata service:
Lines 428 to 431 in 46a3b35
| String defaultValue = textInputs.get(name); | |
| if (defaultValue!=null) { | |
| fields.add(new StringFieldModel(name, defaultValue).label(e.getValue())); | |
| } |
String defaultValue = textInputs.get(name);
if (defaultValue!=null) {
fields.add(new StringFieldModel(name, defaultValue).label(e.getValue()));
}If the Initializr service ever returns an empty string (not null) as the default for the name field, this check passes it straight through, so the name field's LiveVariable starts out as "" instead of a sane fallback like demo.
2. NameGenerator has no guard against an empty prefix:
public NameGenerator(String previousName) {
prefix = previousName.replace(' ', '-');
...
}
public String generateNext() {
StringBuilder sb = new StringBuilder();
sb.append(prefix);
sb.append(delimiter); // "-"
sb.append(++number); // 1
return sb.toString();
}NewProjectNameValidator correctly flags an empty project name as invalid ("Project name is empty"), which makes NewSpringBootWizardModel#generateValidProjectName() call new NameGenerator(projectName.getValue()) to "fix" it:
Lines 200 to 210 in 46a3b35
| private void generateValidProjectName() { | |
| boolean projectNameValid = projectName.getValidator().getValue() == ValidationResult.OK; | |
| if (!projectNameValid) { | |
| NameGenerator generator = new NameGenerator(projectName.getValue()); | |
| int limit = 5; //See: https://github.com/spring-projects/spring-ide/issues/230 | |
| while (!projectNameValid && limit-- > 0) { | |
| projectName.setValue(generator.generateNext()); | |
| projectNameValid = projectName.getValidator().getValue() == ValidationResult.OK; | |
| } | |
| } | |
| } |
With an empty input, prefix ends up "", and generateNext() returns "" + "-" + "1" = -1 — a value that looks like a plausible auto-incremented name but is actually meaningless, and is itself accepted as valid by the name validator (no leading-character restriction), so the loop stops immediately and the UI shows -1 as if it were normal.
Reproduction (headless, no UI)
Instantiating the model directly and reading the name field reproduces the issue deterministically:
NewSpringBootWizardModel model = new NewSpringBootWizardModel();
FieldModel<String> nameField = model.stringInputs.getField("name");
System.out.println(nameField.getValue()); // prints "-1"Suggested fix
- In
discoverOptions, treat a blank string the same asnull(e.g.if (defaultValue != null && !defaultValue.isBlank())) so a field never starts out empty when a fallback default is more appropriate. - In
NameGenerator, fall back to a non-empty prefix (e.g."project"or reject empty input) so it can never emit a name consisting of only a delimiter and a number.
Either fix alone would prevent the -1 from ever reaching the UI.
Environment
org.springframework.ide.eclipse.boot.wizard5.2.0.202606090740 (Eclipse 2026-06 based product)- Also present in
mainas of commit 46a3b35 (both files unchanged since 2020/2022 respectively)
Activity
martinlippert commentedon Jul 6, 2026
Thanks for reporting this. Do you have any idea how to reproduce this from a running IDE instance from the UI ? Would be interesting to learn under what circumstances this happens (for the user).
GH-1927: use artifact as default for the project name if there is no …