{"record":{"id":"2c863c2d4491b67f","repo":"apache/maven","slug":"single-version-must-be-surrounded-by","errorCode":null,"errorMessage":"Single version must be surrounded by []: {}","messagePattern":"Single version must be surrounded by \\[\\]: (.+?)","errorType":"validation","errorClass":"InvalidVersionSpecificationException","httpStatus":null,"severity":"warning","filePath":"compat/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java","lineNumber":173,"sourceCode":"\n        cached = new VersionRange(version, restrictions);\n        CACHE_SPEC.put(spec, cached);\n        return cached;\n    }\n\n    private static Restriction parseRestriction(String spec) throws InvalidVersionSpecificationException {\n        boolean lowerBoundInclusive = spec.startsWith(\"[\");\n        boolean upperBoundInclusive = spec.endsWith(\"]\");\n\n        String process = spec.substring(1, spec.length() - 1).trim();\n\n        Restriction restriction;\n\n        int index = process.indexOf(',');\n\n        if (index < 0) {\n            if (!lowerBoundInclusive || !upperBoundInclusive) {\n                throw new InvalidVersionSpecificationException(\"Single version must be surrounded by []: \" + spec);\n            }\n\n            ArtifactVersion version = new DefaultArtifactVersion(process);\n\n            restriction = new Restriction(version, lowerBoundInclusive, version, upperBoundInclusive);\n        } else {\n            String lowerBound = process.substring(0, index).trim();\n            String upperBound = process.substring(index + 1).trim();\n\n            ArtifactVersion lowerVersion = null;\n            if (!lowerBound.isEmpty()) {\n                lowerVersion = new DefaultArtifactVersion(lowerBound);\n            }\n            ArtifactVersion upperVersion = null;\n            if (!upperBound.isEmpty()) {\n                upperVersion = new DefaultArtifactVersion(upperBound);\n            }\n","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/VersionRange.java#L155-L191","documentation":"The per-problem detail line under the toolchains header: each Problem is printed as 'message @ location', where location is the toolchains source file when identifiable, otherwise the default toolchains file path. Fixing every line removes the whole warning block.","triggerScenarios":"Any toolchains-building problem: XML that does not parse at that location, a toolchain entry missing required fields, or invalid values detected while merging user and project sources.","commonSituations":"Multiple toolchains sources (user plus project) making it unclear which file the location refers to; provisioning scripts emitting syntactically valid but semantically incomplete entries.","solutions":["Open the file named before the @ and apply the message at the reported position","If the location is not a path you recognize, run mvn -X: earlier debug lines show which toolchains sources were read","Correct or delete the broken <toolchain> entry and rebuild"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for f in ~/.m2/toolchains.xml .mvn/toolchains.xml; do\n  [ -f $f ] && xmllint --noout $f\n done","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fix every reported 'message @ location' pair, not just the first","Keep only one toolchains source (user or project) so locations stay unambiguous"],"tags":["maven","toolchains","configuration","diagnostics","maven-embedder"],"backgroundTag":"toolchains-xml-invalid","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}