Skip to content

New Spring Starter Project wizard shows "-1" instead of "demo" as default project name #1927

Closed

Description

@cypher256

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:

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:

https://github.com/spring-projects/spring-tools/blob/46a3b356d75d4575c0345bdaf046ae37e3cb1510/eclipse-language-servers/org.springsource.ide.eclipse.commons.core/src/org/springsource/ide/eclipse/commons/core/util/NameGenerator.java

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:

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 as null (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.wizard 5.2.0.202606090740 (Eclipse 2026-06 based product)
  • Also present in main as of commit 46a3b35 (both files unchanged since 2020/2022 respectively)

Activity

  1. martinlippert commented on Jul 6, 2026

    @martinlippert
    Member

    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).

  2. added this to the 5.3.0.RELEASE milestone on Jul 6, 2026
  3. added a commit that references this issue on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

for: eclipsetheme: getting-startedtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions