{"record":{"id":"5d06e3e1210ea206","repo":"dotnet/aspnetcore","slug":"the-name-argument-is-required","errorCode":null,"errorMessage":"The '${name}' argument is required.","messagePattern":"The '(.+?)' argument is required\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/Utils.ts","lineNumber":20,"sourceCode":"// The .NET Foundation licenses this file to you under the MIT license.\n\nimport { HttpClient } from \"./HttpClient\";\nimport { ILogger, LogLevel } from \"./ILogger\";\nimport { NullLogger } from \"./Loggers\";\nimport { IStreamSubscriber, ISubscription } from \"./Stream\";\nimport { Subject } from \"./Subject\";\nimport { IHttpConnectionOptions } from \"./IHttpConnectionOptions\";\nimport { VERSION } from \"./pkg-version\";\n\n// Version token that will be replaced by the prepack command\n/** The version of the SignalR client. */\n\nexport { VERSION };\n/** @private */\nexport class Arg {\n    public static isRequired(val: any, name: string): void {\n        if (val === null || val === undefined) {\n            throw new Error(`The '${name}' argument is required.`);\n        }\n    }\n    public static isNotEmpty(val: string, name: string): void {\n        if (!val || val.match(/^\\s*$/)) {\n            throw new Error(`The '${name}' argument should not be empty.`);\n        }\n    }\n\n    public static isIn(val: any, values: any, name: string): void {\n        // TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.\n        if (!(val in values)) {\n            throw new Error(`Unknown ${name} value: ${val}.`);\n        }\n    }\n}\n\n/** @private */\nexport class Platform {","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr/src/Utils.ts#L2-L38","documentation":"Arg.isRequired is a guard used across public APIs (connection builders, transport.connect, hub methods) that throws when a mandatory argument is null or undefined. It is the standard precondition check for required parameters.","triggerScenarios":"Calling an internal/public API with null or undefined for a required parameter, e.g. withUrl(null), transport.connect(undefined, format), or Arg.isRequired(myVar, 'myVar') where myVar is undefined.","commonSituations":"Passing an uninitialized variable, a config object whose field is missing, or destructuring defaults that resolve to undefined. Pure programmer error.","solutions":["Pass a concrete value for the argument named in the message.","Initialize variables before use and provide defaults at the call site.","Add your own Arg.isRequired or null check earlier to surface the missing value with more context.","Review the stack trace to find which API call omitted the argument."],"exampleFix":"// before\nconst url = config.url; // undefined\nconst conn = new HubConnection(url); // throws\n\n// after\nconst url = config.url;\nif (url == null) throw new Error('config.url is required');\nconst conn = new HubConnection(url);","handlingStrategy":"validation","validationCode":"function requireArg<T>(val: T | null | undefined, name: string): T {\n  if (val === null || val === undefined) {\n    throw new Error(`Missing required argument '${name}'`);\n  }\n  return val;\n}","typeGuard":"function isPresent<T>(v: T | null | undefined): v is T {\n  return v !== null && v !== undefined;\n}","tryCatchPattern":null,"preventionTips":["Validate required arguments in your own wrapper before calling SignalR APIs.","Initialize config fields with defaults or fail fast at load time.","Enable strict null checks so undefined flows are caught at compile time."],"tags":["typescript","signalr","validation","argument-validation"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}