{"record":{"id":"82f0534da80937b9","repo":"quarkusio/quarkus","slug":"uri-is-null","errorCode":null,"errorMessage":"URI is null","messagePattern":"URI is null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java","lineNumber":250,"sourceCode":"        }\n        if (match.group(7) != null)\n            replaceQuery(match.group(7));\n        if (match.group(9) != null)\n            fragment(match.group(9));\n        return this;\n    }\n\n    public UriBuilder uri(String uriTemplate) throws IllegalArgumentException {\n        return uriTemplate(uriTemplate);\n    }\n\n    public UriBuilder uriFromCharSequence(CharSequence uriTemplate) throws IllegalArgumentException {\n        return uriTemplate(uriTemplate);\n    }\n\n    public UriBuilder uri(URI uri) throws IllegalArgumentException {\n        if (uri == null)\n            throw new IllegalArgumentException(\"URI is null\");\n\n        if (uri.getRawFragment() != null)\n            fragment = uri.getRawFragment();\n\n        if (uri.isOpaque()) {\n            scheme = uri.getScheme();\n            ssp = uri.getRawSchemeSpecificPart();\n            return this;\n        }\n\n        if (uri.getScheme() == null) {\n            if (ssp != null) {\n                if (uri.getRawSchemeSpecificPart() != null) {\n                    ssp = uri.getRawSchemeSpecificPart();\n                    return this;\n                }\n            }\n        } else {","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/common/runtime/src/main/java/org/jboss/resteasy/reactive/common/jaxrs/UriBuilderImpl.java#L232-L268","documentation":"UriBuilderImpl.uri(URI) throws 'URI is null' when the caller passes a null java.net.URI. The JAX-RS UriBuilder contract requires IllegalArgumentException for invalid arguments and null is treated as invalid. The guard fires before any URI component merging happens.","triggerScenarios":"Calling builder.uri(null) directly, or passing a URI variable that is null because optional configuration was absent or a lookup/factory method returned null instead of throwing.","commonSituations":"REST client base URI read from optional config that is not set; factory methods returning null on failure; refactors that made a previously-validated URI field nullable.","solutions":["Null-check before calling: if (uri != null) builder.uri(uri); else use a default","Make the URI source throw on failure (URI.create) rather than return null","Provide a fallback default URI when configuration is absent","Fail fast with Objects.requireNonNull(uri, 'uri') at your call site"],"exampleFix":"// before: URI base = loadBaseUri(); // may return null; builder.uri(base) throws // after: URI base = loadBaseUri(); if (base == null) throw new IllegalStateException('base URI must be configured'); builder.uri(base);","handlingStrategy":"type-guard","validationCode":"static URI nonNullUri(URI uri, URI fallback) {\n    return uri != null ? uri : java.util.Objects.requireNonNull(fallback, 'no base URI configured');\n}","typeGuard":"static boolean hasUri(URI uri) {\n    return uri != null;\n}","tryCatchPattern":"try {\n    builder.uri(uri);\n} catch (IllegalArgumentException e) {\n    if (uri == null)\n        throw new IllegalStateException('Base URI is not configured; check quarkus.rest-client settings', e);\n    throw e;\n}","preventionTips":["Null-check URIs read from optional configuration before building","Let URI.create() throw instead of returning null from lookup helpers","Validate mandatory base URIs at startup"],"tags":["resteasy-reactive","jaxrs","uri","null-check","illegal-argument"],"backgroundTag":"null-argument","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}