{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/java/signalr/core/src/main/java/com/microsoft/signalr/HubConnectionBuilder.java#L1-L29","documentation":"HubConnectionBuilder.create(url) rejects a null or empty URL with IllegalArgumentException. The URL is the hub endpoint and is mandatory; without a valid URL the builder cannot construct a connection. This is a fail-fast precondition check.","triggerScenarios":"Passing null, \"\", or a whitespace-only string to HubConnectionBuilder.create(); reading the URL from a config property/environment variable that resolved to null; building the URL via string concatenation with a null field.","commonSituations":"Missing environment variable or appsettings key; property typo; URL field not injected (DI/serialization left it null); build-time placeholder never replaced.","solutions":["Provide a valid absolute hub URL such as https://host/hub.","Null/empty-check the resolved config value before calling create() and fail fast with a clear message.","Validate the URL format at app startup rather than at first connection."],"exampleFix":"// before\nHubConnection conn = HubConnectionBuilder.create(url).build();\n\n// after\nif (url == null || url.trim().isEmpty()) {\n    throw new IllegalStateException(\"SignalR hub URL is not configured\");\n}\nHubConnection conn = HubConnectionBuilder.create(url).build();","handlingStrategy":"validation","validationCode":"// Java\nif (url == null || url.trim().isEmpty()) {\n    throw new IllegalStateException(\"SignalR hub URL is not configured\");\n}\nHubConnectionBuilder.create(url);","typeGuard":null,"tryCatchPattern":"try {\n    HubConnectionBuilder.create(url);\n} catch (IllegalArgumentException ex) {\n    // surface configuration error clearly\n}","preventionTips":["Resolve and validate the hub URL at app startup, not at first connection.","Treat a missing URL property as a build/deploy-time failure.","Guard config readers so null never reaches the builder."],"tags":["signalr","configuration","validation","java"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}