{"record":{"id":"0d9c031cba49d5d1","repo":"apache/maven","slug":"not-yet-implemented-0d9c03","errorCode":null,"errorMessage":"Not yet implemented","messagePattern":"Not yet implemented","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultSession.java","lineNumber":240,"sourceCode":"        if (repository instanceof DefaultRemoteRepository defaultRemoteRepository) {\n            org.eclipse.aether.repository.RemoteRepository rr = defaultRemoteRepository.getRepository();\n\n            try {\n                return mavenRepositorySystem.createRepository(\n                        rr.getUrl(),\n                        rr.getId(),\n                        rr.getPolicy(false).isEnabled(),\n                        rr.getPolicy(false).getUpdatePolicy(),\n                        rr.getPolicy(true).isEnabled(),\n                        rr.getPolicy(true).getUpdatePolicy(),\n                        rr.getPolicy(false).getChecksumPolicy());\n\n            } catch (Exception e) {\n                throw new RuntimeException(\"Unable to create repository\", e);\n            }\n        } else {\n            // TODO\n            throw new UnsupportedOperationException(\"Not yet implemented\");\n        }\n    }\n}\n","sourceCodeStart":222,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultSession.java#L222-L244","documentation":"Thrown by DefaultSession.toArtifactRepository() when the RemoteRepository argument is not a DefaultRemoteRepository. The method converts a consumer-API (org.apache.maven.api) RemoteRepository into the legacy ArtifactRepository, but only the default implementation carries the underlying Eclipse Resolver repository needed for the conversion. Any other implementation of the RemoteRepository interface hits the 'TODO' branch and fails with UnsupportedOperationException.","triggerScenarios":"Calling session.toArtifactRepository(repository) with a hand-written or third-party implementation of org.apache.maven.api.repository.RemoteRepository (e.g., a test stub, a mock, or a wrapper created by a custom repository policy), instead of the DefaultRemoteRepository instances produced by DefaultSession.newResolutionRepository()/repository session factories.","commonSituations":"Embedding Maven and wrapping RemoteRepository objects to customize releases/snapshots policy; mocking RemoteRepository in unit tests; upgrading a library that previously accepted any implementation and now enforces the concrete type.","solutions":["Only pass RemoteRepository instances obtained from the Session itself (session.getRemoteRepositories(), newResolutionRepository) so they are DefaultRemoteRepository","If you wrap repositories, unwrap/delegate to the original DefaultRemoteRepository before calling toArtifactRepository","In tests, construct DefaultRemoteRepository (or use the session factory) instead of mocking the interface","If you genuinely need a custom RemoteRepository converted, raise it upstream — the branch is an explicit TODO and unimplemented"],"exampleFix":"// before\nRemoteRepository custom = new MyRemoteRepository(...);\nArtifactRepository ar = session.toArtifactRepository(custom); // UnsupportedOperationException\n\n// after\nDefaultRemoteRepository dr = (DefaultRemoteRepository) session.getRemoteRepositories().get(0);\nArtifactRepository ar = session.toArtifactRepository(dr);","handlingStrategy":"validation","validationCode":"// before calling session.toArtifactRepository(r)\nif (!(repository instanceof org.apache.maven.internal.impl.DefaultRemoteRepository)) {\n    throw new IllegalArgumentException(\"Unsupported RemoteRepository implementation: \" + repository.getClass().getName());\n}","typeGuard":"boolean isConvertible(org.apache.maven.api.repository.RemoteRepository r) {\n    return r instanceof org.apache.maven.internal.impl.DefaultRemoteRepository;\n}","tryCatchPattern":"try {\n    ArtifactRepository ar = session.toArtifactRepository(r);\n} catch (UnsupportedOperationException e) {\n    // fall back: construct the legacy ArtifactRepository via ArtifactRepositoryFactory\n}","preventionTips":["Always source RemoteRepository instances from the Session API rather than implementing the interface yourself","Wrap-and-delegate: keep the original DefaultRemoteRepository reachable inside custom wrappers","In tests, build real sessions instead of mocking RemoteRepository"],"tags":["maven","unsupported-operation","type-check","repository","embedding"],"backgroundTag":"unsupported-operation-unimplemented-path","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}