{"record":{"id":"6b174751cab74395","repo":"apache/maven","slug":"supplied-uri-is-not-relative","errorCode":null,"errorMessage":"Supplied URI is not relative","messagePattern":"Supplied URI is not relative","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultTransport.java","lineNumber":50,"sourceCode":"import org.eclipse.aether.spi.connector.transport.Transporter;\n\nimport static java.util.Objects.requireNonNull;\n\npublic class DefaultTransport implements Transport {\n    private final URI baseURI;\n    private final Transporter transporter;\n\n    public DefaultTransport(URI baseURI, Transporter transporter) {\n        this.baseURI = requireNonNull(baseURI);\n        this.transporter = requireNonNull(transporter);\n    }\n\n    @Override\n    public boolean get(URI relativeSource, Path target) {\n        requireNonNull(relativeSource, \"relativeSource is null\");\n        requireNonNull(target, \"target is null\");\n        if (relativeSource.isAbsolute()) {\n            throw new IllegalArgumentException(\"Supplied URI is not relative\");\n        }\n        URI source = baseURI.resolve(relativeSource);\n        if (!source.toASCIIString().startsWith(baseURI.toASCIIString())) {\n            throw new IllegalArgumentException(\"Supplied relative URI escapes baseUrl\");\n        }\n        GetTask getTask = new GetTask(source);\n        getTask.setDataPath(target);\n        try {\n            transporter.get(getTask);\n            return true;\n        } catch (Exception e) {\n            if (Transporter.ERROR_NOT_FOUND != transporter.classify(e)) {\n                throw new RuntimeException(e);\n            }\n            return false;\n        }\n    }\n","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultTransport.java#L32-L68","documentation":"Transport.get(URI relativeSource, Path target) only accepts a relative URI: the URI is resolved against the transport's baseURI (the remote repository URL) before fetching. An absolute URI (one with a scheme, so URI.isAbsolute() is true) is rejected immediately with IllegalArgumentException, because the API is designed exclusively for base-relative downloads.","triggerScenarios":"Calling transport.get(URI.create(\"https://repo.maven.apache.org/maven2/org/foo/x.jar\"), path) or any URI with a scheme such as file:/x, http://..., or a network-path reference that URI.isAbsolute() reports as absolute.","commonSituations":"Embedders mixing fully-qualified artifact URLs with the Transport API; code migrated from a raw HttpClient that always used absolute URLs; computing the artifact path but forgetting to strip the repository base URL.","solutions":["Strip the repository base URL and pass only the remaining path, e.g. \"org/apache/maven/maven-core/3.9.0/maven-core-3.9.0.jar\"","If you must fetch an arbitrary absolute URL, create the transport with that URL as its base via TransportProvider.transport(session, remoteRepository) instead","Derive the relative URI with baseURI.relativize(absoluteURI) rather than string concatenation"],"exampleFix":"// before\nURI src = URI.create(\"https://repo.example.com/repo/com/acme/a/1.0/a-1.0.jar\");\ntransport.get(src, target);\n\n// after: pass only the base-relative path\nURI src = URI.create(\"com/acme/a/1.0/a-1.0.jar\");\ntransport.get(src, target);","handlingStrategy":"validation","validationCode":"URI src = ...;\nif (src.isAbsolute()) {\n    src = baseURI.relativize(src); // or reject: throw new IllegalArgumentException(\"absolute URI: \" + src)\n}\ntransport.get(src, target);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat Transport as base-relative: compute paths from artifact coordinates, never full URLs","Derive relative URIs with baseURI.relativize(absoluteURI) instead of string subtraction","Unit-test path construction so it never contains a scheme"],"tags":["maven","resolver","transport","uri","validation"],"backgroundTag":"invalid-uri","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}