alibaba/spring-ai-alibaba · warning

Failed to parse version number

Error message

Failed to parse version number: {}, using fallback

What it means

VersionUtils.generateVersionNumber parses a dotted version string and returns a bumped 'major.(minor+1).0' version. If any numeric component fails Integer.parseInt, it logs this warning and falls back to appending a timestamp to the original version string instead of throwing.

Solutions

  1. Ensure currentVersion is plain dotted integers (e.g. '1.2.3') before calling generateVersionNumber
  2. Strip suffixes like -SNAPSHOT/-beta before invoking, and re-add them to the result
  3. Accept the timestamp fallback if uniqueness matters more than format
  4. Improve the utility to split on non-digits and ignore non-numeric parts

Example fix

// before
String next = VersionUtils.generateVersionNumber("1.0.0-SNAPSHOT"); // warns, returns '1.0.0-SNAPSHOT.<ts>'
// after
String base = "1.0.0-SNAPSHOT".split("-")[0];
String next = VersionUtils.generateVersionNumber(base) + "-SNAPSHOT";
Defensive patterns

Strategy: validation

Validate before calling

if (currentVersion == null || !currentVersion.matches("\\d+(\\.\\d+)*")) { throw new IllegalArgumentException("Version must be dotted integers: " + currentVersion); }

Type guard

static boolean isPlainDottedVersion(String v) { return v != null && v.matches("\\d+(\\.\\d+)*"); }

Prevention

When it happens

Trigger: Calling generateVersionNumber with a currentVersion string whose components are not plain integers, e.g. '1.0.0-SNAPSHOT', '2.3.4-beta', or a non-numeric garbage string.

Common situations: Dev/snapshot versions like '1.0.0-SNAPSHOT' or build-metadata suffixes passed in; environment variables or config files carrying a malformed version; locale-formatted version strings.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/432d442255768dff. Report an issue: GitHub.

Appendix: source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/VersionUtils.java:34

        if (StringUtils.isBlank(currentVersion)){
            return "1.0.0";
        }

        try {
            String[] parts = currentVersion.split("\\.");
            if (parts.length >= 3) {
                int major = Integer.parseInt(parts[0]);
                int minor = Integer.parseInt(parts[1]);
                int patch = Integer.parseInt(parts[2]);
                return major + "." + minor + "." + (patch + 1);
            } else {
                int major = Integer.parseInt(parts[0]);
                int minor = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;
                return major + "." + (minor + 1) + ".0";
            }
        } catch (NumberFormatException e) {
            log.warn("Failed to parse version number: {}, using fallback", currentVersion, e);
            return currentVersion + "." + System.currentTimeMillis();
        }
    }

}

View on GitHub (pinned to f82da0b50f)