dotnet/aspnetcore · error · Error

The '${name}' argument should not be empty.

Error message

The '${name}' argument should not be empty.

What it means

Arg.isNotEmpty validates that a string argument is neither empty nor whitespace-only (regex /^\s*$/). It complements isRequired for string parameters where blank values are semantically invalid, e.g. a url or a hub method name.

Source

Thrown at src/SignalR/clients/ts/signalr/src/Utils.ts:25

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 {
    // react-native has a window but no document so we should check both
    public static get isBrowser(): boolean {
        return !Platform.isNode && typeof window === "object" && typeof window.document === "object";
    }

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Supply a non-blank string value for the named argument.
  2. Trim and validate config strings at load time before passing them to SignalR APIs.
  3. Fail fast with a clearer message in your own code if the trimmed value is empty.
  4. Check environment variables / config files for missing or whitespace entries.

Example fix

// before
const url = process.env.HUB_URL; // '' or '   '
Arg.isNotEmpty(url, 'url'); // throws

// after
const url = (process.env.HUB_URL || '').trim();
if (!url) throw new Error('HUB_URL must be set');
Arg.isNotEmpty(url, 'url');
Defensive patterns

Strategy: validation

Validate before calling

function requireNonEmpty(val: string | null | undefined, name: string): string {
  const v = (val ?? '').trim();
  if (!v) throw new Error(`Argument '${name}' must not be empty`);
  return v;
}

Type guard

function isNonEmptyString(v: unknown): v is string {
  return typeof v === 'string' && v.trim().length > 0;
}

Prevention

When it happens

Trigger: Passing '', ' ', or a whitespace-only string to an API guarded by Arg.isNotEmpty (url construction, method names).

Common situations: Empty config value read from env/file, a typo leaving the string blank, or trimming that produces an empty string.

Related errors


AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06). Data as JSON: /api/errors/a3c2b804e40bbd30. Report an issue: GitHub.