apache/maven · error · InvalidRepositoryException

Repository identifier missing

Error message

Repository identifier missing

What it means

MavenRepositorySystem.buildArtifactRepository(model.Repository) validates every `<repository>`/`<pluginRepository>` declaration of a POM before creating the ArtifactRepository; a declaration whose `<id>` is null or empty fails immediately with InvalidRepositoryException 'Repository identifier missing' (exception key is the empty string). The id is the identity used for settings.xml mirror and server matching, so it is mandatory.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/bridge/MavenRepositorySystem.java:333

            modelRepositoryPolicy.setEnabled(settingsRepositoryPolicy.isEnabled());
            modelRepositoryPolicy.setUpdatePolicy(settingsRepositoryPolicy.getUpdatePolicy());
            modelRepositoryPolicy.setChecksumPolicy(settingsRepositoryPolicy.getChecksumPolicy());
        }
        return modelRepositoryPolicy;
    }

    public static ArtifactRepository buildArtifactRepository(org.apache.maven.settings.Repository repo)
            throws InvalidRepositoryException {
        return buildArtifactRepository(fromSettingsRepository(repo));
    }

    public static ArtifactRepository buildArtifactRepository(org.apache.maven.model.Repository repo)
            throws InvalidRepositoryException {
        if (repo != null) {
            String id = repo.getId();

            if (id == null || id.isEmpty()) {
                throw new InvalidRepositoryException("Repository identifier missing", "");
            }

            String url = repo.getUrl();

            if (url == null || url.isEmpty()) {
                throw new InvalidRepositoryException("URL missing for repository " + id, id);
            }

            ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy(repo.getSnapshots());

            ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy(repo.getReleases());

            ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

            return createArtifactRepository(id, url, layout, snapshots, releases);
        } else {
            return null;
        }

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Find the block: `grep -rn '<repository>' --include=pom.xml .` and add a unique non-empty `<id>`.
  2. Use a stable id if settings.xml mirrors or credentials will be attached to it.
  3. Verify with `mvn validate` or `mvn help:effective-pom` after the fix.

Example fix

<!-- before -->
<repository>
  <url>https://repo.example.com/public</url>
</repository>

<!-- after -->
<repository>
  <id>example-public</id>
  <url>https://repo.example.com/public</url>
</repository>
Defensive patterns

Strategy: validation

Validate before calling

for (org.apache.maven.model.Repository r : model.getRepositories()) {
    if (r.getId() == null || r.getId().isEmpty()) {
        throw new IllegalArgumentException("Repository without <id> in " + model.getPomFile());
    }
}

Prevention

When it happens

Trigger: A `<repository>` block with `<url>` but no `<id>` (or `<id/>`) in pom.xml, a profile, pluginRepositories, or distributionManagement of a POM being turned into a repository.

Common situations: Hand-written or templated repository blocks with placeholder ids never filled in; IDE stanzas inserted incomplete; POMs ported from tools that tolerated missing ids.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/1f242578c87c23f9. Report an issue: GitHub.