dotnet/aspnetcore · error · Error
The '${name}' argument is required.
Error message
The '${name}' argument is required. What it means
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.
Source
Thrown at src/SignalR/clients/ts/signalr/src/Utils.ts:20
// The .NET Foundation licenses this file to you under the MIT license.
import { HttpClient } from "./HttpClient";
import { ILogger, LogLevel } from "./ILogger";
import { NullLogger } from "./Loggers";
import { IStreamSubscriber, ISubscription } from "./Stream";
import { Subject } from "./Subject";
import { IHttpConnectionOptions } from "./IHttpConnectionOptions";
import { VERSION } from "./pkg-version";
// Version token that will be replaced by the prepack command
/** The version of the SignalR client. */
export { VERSION };
/** @private */
export class Arg {
public static isRequired(val: any, name: string): void {
if (val === null || val === undefined) {
throw new Error(`The '${name}' argument is required.`);
}
}
public static isNotEmpty(val: string, name: string): void {
if (!val || val.match(/^\s*$/)) {
throw new Error(`The '${name}' argument should not be empty.`);
}
}
public static isIn(val: any, values: any, name: string): void {
// TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.
if (!(val in values)) {
throw new Error(`Unknown ${name} value: ${val}.`);
}
}
}
/** @private */
export class Platform {View on GitHub (pinned to 294cab2f9b)
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.
Example fix
// before
const url = config.url; // undefined
const conn = new HubConnection(url); // throws
// after
const url = config.url;
if (url == null) throw new Error('config.url is required');
const conn = new HubConnection(url); Defensive patterns
Strategy: validation
Validate before calling
function requireArg<T>(val: T | null | undefined, name: string): T {
if (val === null || val === undefined) {
throw new Error(`Missing required argument '${name}'`);
}
return val;
} Type guard
function isPresent<T>(v: T | null | undefined): v is T {
return v !== null && v !== undefined;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Passing an uninitialized variable, a config object whose field is missing, or destructuring defaults that resolve to undefined. Pure programmer error.
Related errors
- The '${name}' argument should not be empty.
- Unknown ${name} value: ${val}.
- Invalid input for JSON hub protocol. Expected a string.
- Invalid payload.
- Invalid payload for StreamItem message.
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/5d06e3e1210ea206.
Report an issue: GitHub.