{"record":{"id":"014338d8c6262052","repo":"apache/maven","slug":"error-building-settings","errorCode":null,"errorMessage":"Error building settings","messagePattern":"Error building settings","errorType":"exception","errorClass":"SettingsBuilderException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsBuilder.java","lineNumber":142,"sourceCode":"            effective = Settings.newBuilder(effective)\n                    .repositories(List.of(central))\n                    .pluginRepositories(List.of(centralWithNoUpdate))\n                    .build();\n        }\n\n        // resolve relative local repository paths to absolute to save plugins from trouble.\n        // paths containing property placeholders like ${user.home} must be left as-is\n        // so that later interpolation can resolve them.\n        String localRepository = effective.getLocalRepository();\n        if (localRepository != null && !localRepository.isEmpty()) {\n            Path file = Paths.get(localRepository);\n            if (!file.isAbsolute() && !localRepository.contains(\"${\")) {\n                effective = effective.withLocalRepository(file.toAbsolutePath().toString());\n            }\n        }\n\n        if (problems.hasErrorProblems()) {\n            throw new SettingsBuilderException(\"Error building settings\", problems);\n        }\n\n        return new DefaultSettingsBuilderResult(request, effective, problems);\n    }\n\n    private Settings readSettings(\n            Source settingsSource,\n            boolean isProjectSettings,\n            SettingsBuilderRequest request,\n            ProblemCollector<BuilderProblem> problems) {\n        if (settingsSource == null) {\n            return Settings.newInstance();\n        }\n\n        Settings settings;\n\n        try {\n            try (InputStream is = settingsSource.openStream()) {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultSettingsBuilder.java#L124-L160","documentation":"Thrown by DefaultSettingsBuilder.build when the merged settings (installation, user and project sources) accumulate error-severity problems, for example an unparseable settings.xml. The exception carries the full ProblemCollector of BuilderProblem entries; iterating them gives each message and source location. Note the builder resolves a relative localRepository to an absolute path before the error check.","triggerScenarios":"A settings.xml source (global, user, or .mvn project settings) with XML parse errors or values the reader reports as ERROR severity; SettingsBuilderRequest sources that exist but cannot be read or interpolated.","commonSituations":"Hand-edited ~/.m2/settings.xml with unclosed tags; CI provisioning that truncates settings files; sharing settings files between Maven versions where validation strictness differs.","solutions":["Catch SettingsBuilderException and iterate the attached problem collector - each problem names its file and line","Fix or reformat the settings.xml at the reported location","Temporarily replace the offending settings file with a minimal valid one to confirm which source is at fault"],"exampleFix":"// before\nSettingsBuilderResult result = settingsBuilder.build(request);\n\n// after\ntry {\n    SettingsBuilderResult result = settingsBuilder.build(request);\n} catch (SettingsBuilderException e) {\n    e.getProblemCollector().getProblems()\n        .forEach(p -> log.error(\"{}: {}\", p.getLocation(), p.getMessage()));\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    SettingsBuilderResult result = settingsBuilder.build(request);\n} catch (SettingsBuilderException e) {\n    e.getProblemCollector().getProblems()\n        .forEach(p -> log.error(\"{}: {}\", p.getLocation(), p.getMessage()));\n    // degrade gracefully: fall back to defaults or a minimal settings file\n}","preventionTips":["Validate settings.xml files in CI provisioning before Maven runs (xmllint)","Iterate the problem collector instead of relying on the exception message alone","Keep user and project settings minimal to reduce merge surface"],"tags":["maven","settings","builder","configuration"],"backgroundTag":"invalid-config-file","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}