{"record":{"id":"0d822a718ac2b7f2","repo":"apache/maven","slug":"repository-identifier-missing","errorCode":null,"errorMessage":"Repository identifier missing","messagePattern":"Repository identifier missing","errorType":"exception","errorClass":"InvalidRepositoryException","httpStatus":null,"severity":"error","filePath":"compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java","lineNumber":692,"sourceCode":"            throws ArtifactTransferFailedException {\n        try {\n            wagonManager.putRemoteFile(\n                    repository, source, remotePath, TransferListenerAdapter.newAdapter(transferListener));\n        } catch (org.apache.maven.wagon.TransferFailedException e) {\n            throw new ArtifactTransferFailedException(getMessage(e, \"Error transferring artifact.\"), e);\n        }\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","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java#L674-L710","documentation":"Thrown by LegacyRepositorySystem.buildArtifactRepository(Repository) when a repository definition carries a null or empty id. Maven requires the repository id because it is the join key for <server> credentials, mirror selection and distribution management, so the model is rejected with InvalidRepositoryException before an ArtifactRepository is created. The exception's repository id is passed as the empty string, since none exists.","triggerScenarios":"Calling buildArtifactRepository(repo) (directly or through DefaultArtifactRepositoryFactory / legacy profile injection) with a Model Repository whose getId() returns null or \"\" — i.e. a POM <repository> or <pluginRepository> block that omits <id> entirely.","commonSituations":"Hand-edited POM with a <repository> that lists only <url> and <releases>/<snapshots>; snippets copied from documentation or Stack Overflow that drop the <id> element; programmatic model building (Maven Model Builder API, flatten plugins, code generators) that forgets repository.setId(...).","solutions":["Add a unique, non-empty <id> to the offending <repository> element in the POM (check <repositories>, <pluginRepositories>, <profiles>, and <distributionManagement>)","If you build the model in code, call repository.setId(\"my-repo\") before invoking buildArtifactRepository","Re-run with mvn help:effective-pom to confirm every injected repository now carries an id","Enable XML schema validation in your editor so an incomplete <repository> block is flagged while editing"],"exampleFix":"<!-- before -->\n<repositories>\n  <repository>\n    <url>https://repo.example.com/maven</url>\n  </repository>\n</repositories>\n\n<!-- after -->\n<repositories>\n  <repository>\n    <id>example</id>\n    <url>https://repo.example.com/maven</url>\n  </repository>\n</repositories>","handlingStrategy":"validation","validationCode":"import org.apache.maven.model.Repository;\n\nboolean isRepositoryDefinitionValid(Repository repo) {\n    return repo != null\n        && repo.getId() != null && !repo.getId().isEmpty();\n}\n\n// before building:\nif (!isRepositoryDefinitionValid(repo)) {\n    throw new IllegalArgumentException(\"Repository definition is missing an id: \" + repo);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ArtifactRepository artifactRepo = legacyRepositorySystem.buildArtifactRepository(repo);\n} catch (InvalidRepositoryException e) {\n    // covers both missing-id and missing-url; e.getMessage() says which\n    log.warn(\"Rejected repository definition: {}\", e.getMessage());\n    throw new BuildConfigurationException(\"Fix POM repository declaration\", e);\n}","preventionTips":["Lint POMs in CI with mvn validate or help:effective-pom so incomplete <repository> blocks fail fast","When generating models programmatically, always pair setId() with setUrl() in the same builder step","Keep POM snippets in a checked template that already includes id, url, releases and snapshots blocks"],"tags":["maven","pom","repository","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"}