{"record":{"id":"0500df99467b9fac","repo":"jhy/jsoup","slug":"url-not-set-make-sure-to-call-url-before-ex","errorCode":null,"errorMessage":"URL not set. Make sure to call #url(...) before executing the request.","messagePattern":"URL not set\\. Make sure to call #url\\(\\.\\.\\.\\) before executing the request\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/helper/HttpConnection.java","lineNumber":444,"sourceCode":"        private Base() {\n            headers = new LinkedHashMap<>();\n            cookies = new LinkedHashMap<>();\n        }\n\n        private Base(Base<T> copy) {\n            url = copy.url; // unmodifiable object\n            method = copy.method;\n            headers = new LinkedHashMap<>();\n            for (Map.Entry<String, List<String>> entry : copy.headers.entrySet()) {\n                headers.put(entry.getKey(), new ArrayList<>(entry.getValue()));\n            }\n            cookies = new LinkedHashMap<>(); cookies.putAll(copy.cookies); // just holds strings\n        }\n\n        @Override\n        public URL url() {\n            if (url == UnsetUrl)\n                throw new IllegalArgumentException(\"URL not set. Make sure to call #url(...) before executing the request.\");\n            return url;\n        }\n\n        @Override\n        public T url(URL url) {\n            Validate.notNullParam(url, \"url\");\n            this.url = new UrlBuilder(url).build();\n            return (T) this;\n        }\n\n        @Override\n        public Method method() {\n            return method;\n        }\n\n        @Override\n        public T method(Method method) {\n            Validate.notNullParam(method, \"method\");","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/helper/HttpConnection.java#L426-L462","documentation":"The request's url() getter throws when the URL was never set: internally the URL field is a sentinel UnsetUrl until url(URL) is called. This surfaces when execute() or any code path asks a RequestBase for its URL before one was configured. It enforces that every request targets an address.","triggerScenarios":"Building a Request/Connection via newRequest() or the Request constructor and calling execute() (or url()) without ever calling url(...); copying a request object that lacked a URL.","commonSituations":"Programmatic request construction (Connection.newRequest()) where url() is set conditionally; test harnesses that forget configuration; code paths that set method/headers/cookies but skip the URL.","solutions":["Call url(URL) or url(String) with an absolute http(s) URL before executing","Add an assertion/validation that the URL field is populated before execute()","Use Jsoup.connect(url) which sets the URL up front"],"exampleFix":"// before\nConnection conn = Jsoup.newRequest();\nconn.method(Connection.Method.POST);\nConnection.Response res = conn.execute();\n// after\nConnection conn = Jsoup.newRequest();\nconn.url(\"https://example.com/api\");\nconn.method(Connection.Method.POST);\nConnection.Response res = conn.execute();","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(requestUrl, \"Request URL must be set before execute()\");","typeGuard":null,"tryCatchPattern":"try { Connection.Response res = conn.execute(); } catch (IllegalArgumentException e) { /* URL was never set: configure and retry */ }","preventionTips":["Build requests through Jsoup.connect(url) so the URL is always set","For newRequest(), set url() immediately after creation","Validate request objects (url, method) in a build() step before executing"],"tags":["java","jsoup","http","missing-config"],"backgroundTag":"missing-required-config","analyzedSha":"9851ac5d9c576c6888910b5a51a2362bbc978959","analyzedAt":"2026-09-08T15:22:04.931Z","contentChangedAt":"2026-09-08T15:22:04.931Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}