{"record":{"id":"c3083ee8fcb81dd8","repo":"dotnet/aspnetcore","slug":"a-valid-url-is-required-c3083e","errorCode":null,"errorMessage":"A valid url is required.","messagePattern":"A valid url is required\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/HubConnectionBuilder.java","lineNumber":18,"sourceCode":"// Licensed to the .NET Foundation under one or more agreements.\n// The .NET Foundation licenses this file to you under the MIT license.\n\npackage com.microsoft.signalr;\n\n/**\n * A builder for configuring {@link HubConnection} instances.\n */\npublic abstract class HubConnectionBuilder {\n    /**\n     * Creates a new instance of {@link HttpHubConnectionBuilder}.\n     *\n     * @param url The URL of the SignalR hub to connect to.\n     * @return An instance of {@link HttpHubConnectionBuilder}.\n     */\n    public static HttpHubConnectionBuilder create(String url) {\n        if (url == null || url.isEmpty()) {\n            throw new IllegalArgumentException(\"A valid url is required.\");\n        }\n        return new HttpHubConnectionBuilder(url);\n    }\n\n    /**\n     * Builds a new instance of {@link HubConnection}.\n     *\n     * @return A new instance of {@link HubConnection}.\n     */\n    public abstract HubConnection build();\n}","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/HubConnectionBuilder.java#L1-L29","documentation":"HubConnectionBuilder.create(url) is the entry point for building a connection. It rejects a null or empty URL string with IllegalArgumentException immediately, before constructing the HttpHubConnectionBuilder. This is a fail-fast precondition on the builder.","triggerScenarios":"Passing null (e.g. from an unset config/properties value) or an empty string (misconfigured env var, blank property) to HubConnectionBuilder.create().","commonSituations":"Reading the hub URL from an environment variable or config file that was not set; string trimming producing empty; typo in property key; dependency injection providing null before configuration is loaded.","solutions":["Validate the URL at application startup: Objects.requireNonNull(url) and url.trim().isEmpty() checks with a clear config error.","Provide a sensible default or fail application bootstrap if the URL property is missing.","Log the source of the URL (env var name, property key) so the misconfiguration is obvious."],"exampleFix":"// before\nString url = System.getenv(\"HUB_URL\"); // null if unset\nHubConnectionBuilder.create(url);\n\n// after\nString url = System.getenv(\"HUB_URL\");\nif (url == null || url.trim().isEmpty()) {\n    throw new IllegalStateException(\"HUB_URL env var must be set\");\n}\nHubConnectionBuilder.create(url.trim());","handlingStrategy":"validation","validationCode":"String url = loadHubUrl();\nif (url == null || url.trim().isEmpty()) {\n  throw new IllegalStateException(\n    \"hub URL is missing (check HUB_URL / config)\");\n}\nHubConnectionBuilder.create(url.trim());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate all config-derived strings at app startup, not at point of use.","Unit-test that missing config fails bootstrap with a clear message.","Centralize config loading so an empty URL is caught once."],"tags":["signalr","java","configuration","validation","builder"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}