{"record":{"id":"67ed38fb221c5f14","repo":"apache/maven","slug":"url-missing-for-repository-id","errorCode":null,"errorMessage":"URL missing for repository \" + id","messagePattern":"URL missing for repository \" \\+ id","errorType":"exception","errorClass":"InvalidRepositoryException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java","lineNumber":698,"sourceCode":"        }\n    }\n\n    //\n    // Artifact Repository Creation\n    //\n    @Override\n    public ArtifactRepository buildArtifactRepository(Repository repo) throws InvalidRepositoryException {\n        if (repo != null) {\n            String id = repo.getId();\n\n            if (id == null || id.isEmpty()) {\n                throw new InvalidRepositoryException(\"Repository identifier missing\", \"\");\n            }\n\n            String url = repo.getUrl();\n\n            if (url == null || url.isEmpty()) {\n                throw new InvalidRepositoryException(\"URL missing for repository \" + id, id);\n            }\n\n            ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy(repo.getSnapshots());\n\n            ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy(repo.getReleases());\n\n            return createArtifactRepository(id, url, getLayout(repo.getLayout()), snapshots, releases);\n        } else {\n            return null;\n        }\n    }\n\n    private ArtifactRepository createRepository(\n            String url,\n            String repositoryId,\n            boolean releases,\n            String releaseUpdates,\n            boolean snapshots,","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java#L680-L716","documentation":"Thrown by LegacyRepositorySystem.buildArtifactRepository(Repository) when a repository definition has a valid id but its url is null or empty. Without a URL Maven cannot compute the artifact request paths for the repository, so the model is rejected with InvalidRepositoryException(\"URL missing for repository <id>\"). The offending repository id is attached to the exception for diagnostics.","triggerScenarios":"A POM <repository>, <pluginRepository>, <distributionManagement> snapshot/release repository, or a programmatically built Repository object where getId() is non-empty but getUrl() returns null or \"\".","commonSituations":"A <repository> block where <id> is present but <url> was accidentally deleted or commented out; property placeholder for the URL resolving to nothing (e.g. <url>${repo.url}</url> with the property undefined, especially in profiles activated per-environment); code that constructs org.apache.maven.model.Repository without calling setUrl().","solutions":["Add the <url> element to the repository whose id appears in the message","If the URL uses a property placeholder, verify the property is defined in the same POM, a loaded profile, or settings.xml and resolves non-empty for the active profile","Run mvn help:effective-pom -Dverbose to see the final resolved repository URLs","When building the model in code, call repository.setUrl(...) before buildArtifactRepository"],"exampleFix":"<!-- before -->\n<repository>\n  <id>example</id>\n  <url>${example.repo.url}</url> <!-- property never defined -->\n</repository>\n\n<!-- after -->\n<properties>\n  <example.repo.url>https://repo.example.com/maven</example.repo.url>\n</properties>\n<repository>\n  <id>example</id>\n  <url>${example.repo.url}</url>\n</repository>","handlingStrategy":"validation","validationCode":"import org.apache.maven.model.Repository;\n\nboolean hasRepositoryUrl(Repository repo) {\n    return repo != null\n        && repo.getId() != null && !repo.getId().isEmpty()\n    && repo.getUrl() != null && !repo.getUrl().isEmpty();\n}\n\nif (!hasRepositoryUrl(repo)) {\n    throw new IllegalArgumentException(\"Repository '\" + repo.getId() + \"' has no URL\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ArtifactRepository artifactRepo = legacyRepositorySystem.buildArtifactRepository(repo);\n} catch (InvalidRepositoryException e) {\n    if (e.getMessage().startsWith(\"URL missing\")) {\n        // repository id is recoverable from the message; report to the user which id lacks a URL\n        reportConfigError(\"Add <url> to repository \" + repo.getId());\n    } else {\n        throw e;\n    }\n}","preventionTips":["Define every repository URL property in the same POM/profile that uses it so it can never resolve empty","Test environment-specific profiles in CI with mvn help:effective-pom to catch unresolved ${...} placeholders","Treat repository declarations as code: review them in PRs like any other config change"],"tags":["maven","pom","repository","url","validation","legacy-compat"],"backgroundTag":"missing-required-field","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}