{"record":{"id":"432d442255768dff","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-parse-version-number-using-fallback","errorCode":null,"errorMessage":"Failed to parse version number: {}, using fallback","messagePattern":"Failed to parse version number: (.+?), using fallback","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/VersionUtils.java","lineNumber":34,"sourceCode":"\n        if (StringUtils.isBlank(currentVersion)){\n            return \"1.0.0\";\n        }\n\n        try {\n            String[] parts = currentVersion.split(\"\\\\.\");\n            if (parts.length >= 3) {\n                int major = Integer.parseInt(parts[0]);\n                int minor = Integer.parseInt(parts[1]);\n                int patch = Integer.parseInt(parts[2]);\n                return major + \".\" + minor + \".\" + (patch + 1);\n            } else {\n                int major = Integer.parseInt(parts[0]);\n                int minor = parts.length > 1 ? Integer.parseInt(parts[1]) : 0;\n                return major + \".\" + (minor + 1) + \".0\";\n            }\n        } catch (NumberFormatException e) {\n            log.warn(\"Failed to parse version number: {}, using fallback\", currentVersion, e);\n            return currentVersion + \".\" + System.currentTimeMillis();\n        }\n    }\n\n}\n","sourceCodeStart":16,"sourceCodeEnd":40,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/utils/VersionUtils.java#L16-L40","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure currentVersion is plain dotted integers (e.g. '1.2.3') before calling generateVersionNumber","Strip suffixes like -SNAPSHOT/-beta before invoking, and re-add them to the result","Accept the timestamp fallback if uniqueness matters more than format","Improve the utility to split on non-digits and ignore non-numeric parts"],"exampleFix":"// before\nString next = VersionUtils.generateVersionNumber(\"1.0.0-SNAPSHOT\"); // warns, returns '1.0.0-SNAPSHOT.<ts>'\n// after\nString base = \"1.0.0-SNAPSHOT\".split(\"-\")[0];\nString next = VersionUtils.generateVersionNumber(base) + \"-SNAPSHOT\";","handlingStrategy":"validation","validationCode":"if (currentVersion == null || !currentVersion.matches(\"\\\\d+(\\\\.\\\\d+)*\")) { throw new IllegalArgumentException(\"Version must be dotted integers: \" + currentVersion); }","typeGuard":"static boolean isPlainDottedVersion(String v) { return v != null && v.matches(\"\\\\d+(\\\\.\\\\d+)*\"); }","tryCatchPattern":null,"preventionTips":["Normalize version strings (strip -SNAPSHOT, +build metadata) before bumping","Unit-test generateVersionNumber against real-world version formats","Document the timestamp fallback behavior so callers aren't surprised"],"tags":["version-parsing","numberformatexception","fallback"],"backgroundTag":"invalid-argument-format","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}