{"record":{"id":"ec6068b16629cb16","repo":"OpenAPITools/openapi-generator","slug":"error-preparing-constraint-for-version-expression","errorCode":null,"errorMessage":"Error preparing constraint for version expression '{requestedVersion}' treated as major version {asSingleNumber}","messagePattern":"Error preparing constraint for version expression '(.+?)' treated as major version (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaHelidonCommonCodegen.java","lineNumber":869,"sourceCode":"                    }\n                }\n            }\n            // The user might have requested a legal version we cannot fully validate because of a network outage\n            // that prevents us from retrieving the current full list of versions, for example. In such cases return the\n            // requested version itself as the best match.\n            return bestMatch != null ? bestMatch.toString() : requestedVersion;\n        }\n\n        private VersionConstraint constraint(VersionScheme versionScheme, String requestedVersion) {\n            try {\n                int asSingleNumber = Integer.parseUnsignedInt(requestedVersion);\n                try {\n                    return versionScheme.parseVersionConstraint(String.format(Locale.getDefault(),\n                            \"[%s,%d-alpha)\",\n                            requestedVersion,\n                            asSingleNumber + 1));\n                } catch (InvalidVersionSpecificationException ex) {\n                    throw new RuntimeException(\"Error preparing constraint for version expression '\"\n                            + requestedVersion\n                            + \"' treated as major version \" + asSingleNumber,\n                            ex);\n                }\n            } catch (NumberFormatException nfe) {\n                try {\n                    return versionScheme.parseVersionConstraint(requestedVersion);\n                } catch (InvalidVersionSpecificationException ex) {\n                    throw new RuntimeException(\"Error parsing version expression '\"\n                            + requestedVersion\n                            + \"' as a version constraint\",\n                            ex);\n                }\n            }\n        }\n\n        /**\n         * Retrieves the list of supported versions from the web site or, failing that, local preferences or, failing that,","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaHelidonCommonCodegen.java#L851-L887","documentation":"Thrown inside JavaHelidonCommonCodegen's VersionConstraint helper when a requested Helidon version parses as a plain unsigned integer (e.g. \"3\") — treated as a major version — but building the range constraint \"[3,4-alpha)\" then fails to parse. It wraps the underlying InvalidVersionSpecificationException, so the message shown is the nested cause's context. In practice this path only fails for Aether/Maven version-scheme inputs that are numeric yet form an invalid range, which is rare.","triggerScenarios":"Passing --additional-properties helidonVersion=3 (bare major) in an environment where the Aether version scheme rejects the synthesized \"[3,4-alpha)\" constraint (unusual/custom version schemes, or a requested number so large that asSingleNumber+1 overflows unsigned parse semantics). Typically seen only when the version-resolution helper is also failing to reach its web/local version lists first.","commonSituations":"Users abbreviating helidonVersion to a single digit expecting 'latest 3.x'. Debug/CI environments with no network where the version-resolution flow behaves differently. This error is a symptom of an unusual version input rather than a mainstream config mistake.","solutions":["Specify a concrete version instead of a bare major: helidonVersion=3.2.0","Or use an explicit Maven-style range: helidonVersion=\"[3.0.0,4.0.0)\"","If you need 'latest 3.x', omit helidonVersion and let the generator resolve its default, or pin a known patch release","Upgrade openapi-generator if you hit this with a plain number — constraint building for major-only input has seen fixes"],"exampleFix":"# before\nopenapi-generator-cli generate -g java-helidon-server -i api.yaml \\\n  --additional-properties helidonVersion=3\n\n# after\nopenapi-generator-cli generate -g java-helidon-server -i api.yaml \\\n  --additional-properties helidonVersion=3.2.0","handlingStrategy":"try-catch","validationCode":"// Reject bare-number version input before generation\nString v = String.valueOf(opts.get(\"helidonVersion\"));\nif (v.matches(\"\\\\d+\")) {\n    throw new IllegalArgumentException(\"helidonVersion must be a full version (e.g. 3.2.0) or Maven range, not a bare number: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.generate();\n} catch (RuntimeException e) {\n    // VersionConstraint helper failures (constraint preparation) — wrap with the offending input\n    if (e.getMessage() != null && e.getMessage().contains(\"constraint\")) {\n        throw new IllegalArgumentException(\"Unparseable helidonVersion '\" + opts.get(\"helidonVersion\") + \"': use '3.2.0' or '[3.0.0,4.0.0)'\", e);\n    }\n    throw e;\n}","preventionTips":["Always pass full x.y.z Helidon versions in configs; reserve bare majors for docs, not inputs","Centralize version strings in one properties file so CI substitution cannot truncate them","Unit-test your config builder with the exact helidonVersion values it can emit"],"tags":["java","helidon","openapi-generator","version-management","maven","version-range"],"backgroundTag":"version-constraint-parse-error","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}