{"record":{"id":"a3c2b804e40bbd30","repo":"dotnet/aspnetcore","slug":"the-name-argument-should-not-be-empty","errorCode":null,"errorMessage":"The '${name}' argument should not be empty.","messagePattern":"The '(.+?)' argument should not be empty\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/Utils.ts","lineNumber":25,"sourceCode":"import { 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 {\n    // react-native has a window but no document so we should check both\n    public static get isBrowser(): boolean {\n        return !Platform.isNode && typeof window === \"object\" && typeof window.document === \"object\";\n    }\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/SignalR/clients/ts/signalr/src/Utils.ts#L7-L43","documentation":"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.","triggerScenarios":"Passing '', '   ', or a whitespace-only string to an API guarded by Arg.isNotEmpty (url construction, method names).","commonSituations":"Empty config value read from env/file, a typo leaving the string blank, or trimming that produces an empty string.","solutions":["Supply a non-blank string value for the named argument.","Trim and validate config strings at load time before passing them to SignalR APIs.","Fail fast with a clearer message in your own code if the trimmed value is empty.","Check environment variables / config files for missing or whitespace entries."],"exampleFix":"// before\nconst url = process.env.HUB_URL; // '' or '   '\nArg.isNotEmpty(url, 'url'); // throws\n\n// after\nconst url = (process.env.HUB_URL || '').trim();\nif (!url) throw new Error('HUB_URL must be set');\nArg.isNotEmpty(url, 'url');","handlingStrategy":"validation","validationCode":"function requireNonEmpty(val: string | null | undefined, name: string): string {\n  const v = (val ?? '').trim();\n  if (!v) throw new Error(`Argument '${name}' must not be empty`);\n  return v;\n}","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Trim and validate config strings (urls, method names) at startup.","Treat empty env values as configuration errors early.","Wrap SignalR calls with your own validated builders."],"tags":["typescript","signalr","validation","argument-validation"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}