{"record":{"id":"82583af771002a90","repo":"flowable/flowable-engine","slug":"baseurl-can-not-be-null-82583a","errorCode":null,"errorMessage":"baseUrl can not be null","messagePattern":"baseUrl can not be null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry-rest/src/main/java/org/flowable/eventregistry/rest/service/api/RestUrlBuilder.java","lineNumber":56,"sourceCode":"    protected RestUrlBuilder() {\n    }\n\n    protected RestUrlBuilder(String baseUrl) {\n        this.baseUrl = baseUrl;\n    }\n\n    public String getBaseUrl() {\n        return baseUrl;\n    }\n\n    public String buildUrl(String[] fragments, Object... arguments) {\n        return new StringBuilder(baseUrl).append(\"/\").append(MessageFormat.format(StringUtils.join(fragments, '/'), arguments)).toString();\n    }\n\n    /** Uses baseUrl as the base URL */\n    public static RestUrlBuilder usingBaseUrl(String baseUrl) {\n        if (baseUrl == null) {\n            throw new FlowableIllegalArgumentException(\"baseUrl can not be null\");\n        }\n        if (baseUrl.endsWith(\"/\")) {\n            baseUrl = baseUrl.substring(0, baseUrl.length() - 1);\n        }\n        return new RestUrlBuilder(baseUrl);\n    }\n\n    /** Extracts the base URL from the request */\n    public static RestUrlBuilder fromRequest(HttpServletRequest request) {\n        return usingBaseUrl(ServletUriComponentsBuilder.fromServletMapping(request).build().toUriString());\n    }\n\n    /** Extracts the base URL from current request */\n    public static RestUrlBuilder fromCurrentRequest() {\n        return usingBaseUrl(ServletUriComponentsBuilder.fromCurrentServletMapping().build().toUriString());\n    }\n}","sourceCodeStart":38,"sourceCodeEnd":73,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry-rest/src/main/java/org/flowable/eventregistry/rest/service/api/RestUrlBuilder.java#L38-L73","documentation":"RestUrlBuilder.usingBaseUrl throws FlowableIllegalArgumentException when given a null baseUrl. This builder constructs HATEOAS-style resource URLs in REST responses, so a base URL is mandatory to build any resource link.","triggerScenarios":"Calling RestUrlBuilder.usingBaseUrl(null) directly, or via fromRequest/fromCurrentRequest when the incoming request carries no usable base URL (e.g. unusual or synthetic request context with null request URL).","commonSituations":"Programmatic use of RestUrlBuilder in tests or custom endpoints passing null; reverse-proxy setups stripping the host so the request URL cannot be reconstructed; calling URL-building code outside an active HTTP request.","solutions":["Pass a non-null baseUrl string to usingBaseUrl, e.g. 'http://localhost:8080/flowable-event-registry-rest'","Ensure fromRequest/fromCurrentRequest is only invoked with a real HttpServletRequest that has a request URL","Check proxy configuration (X-Forwarded-Host / ForwardedFilter) so the base URL can be reconstructed"],"exampleFix":"// before\nRestUrlBuilder builder = RestUrlBuilder.usingBaseUrl(config.getBaseUrl()); // null\n// after\nif (config.getBaseUrl() == null) { config.setBaseUrl(\"http://localhost:8080/flowable-event-registry-rest\"); }\nRestUrlBuilder builder = RestUrlBuilder.usingBaseUrl(config.getBaseUrl());","handlingStrategy":"validation","validationCode":"if (baseUrl == null || baseUrl.isBlank()) {\n    throw new IllegalArgumentException(\"baseUrl must be set before building REST resource URLs\");\n}","typeGuard":"boolean hasBaseUrl = b -> b != null && !b.isBlank();","tryCatchPattern":"try {\n    RestUrlBuilder builder = RestUrlBuilder.usingBaseUrl(baseUrl);\n} catch (FlowableIllegalArgumentException e) {\n    logger.error(\"baseUrl not provided: {}\", e.getMessage());\n}","preventionTips":["Configure the REST app base URL explicitly in properties and validate at startup","Only call fromRequest/fromCurrentRequest within an active HttpServletRequest","When behind a proxy, forward Host/X-Forwarded-* headers so the base URL is derivable"],"tags":["http","rest","validation","null-argument"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}