{"record":{"id":"ecc0ee84b090f9d5","repo":"dotnet/aspnetcore","slug":"unknown-name-value-val","errorCode":null,"errorMessage":"Unknown ${name} value: ${val}.","messagePattern":"Unknown (.+?) value: (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/SignalR/clients/ts/signalr/src/Utils.ts","lineNumber":32,"sourceCode":"\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\n    // WebWorkers don't have a window object so the isBrowser check would fail\n    public static get isWebWorker(): boolean {\n        return !Platform.isNode && typeof self === \"object\" && \"importScripts\" in self;\n    }\n\n    // react-native has a window but no document\n    static get isReactNative(): boolean {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/SignalR/clients/ts/signalr/src/Utils.ts#L14-L50","documentation":"Thrown by Arg.isIn when a value is not present as a key in the supplied enum/values object. TypeScript enums expose both name and value keys, so the check accepts either the enum name or its numeric value. It is used to validate transferFormat against the TransferFormat enum at every transport constructor and at HttpConnection.start.","triggerScenarios":"Passing a transferFormat that is neither TransferFormat.Text (1) nor TransferFormat.Binary (2) - e.g. a raw string 'text', a number like 0 or 3, or undefined. Triggered when constructing WebSocketTransport/LongPollingTransport/ServerSentEventsTransport or calling HttpConnection.start with an invalid format.","commonSituations":"Confusing the string name 'Text' with the enum value; passing a number from a config that is out of range; serializing/deserializing the enum across a boundary and losing the type; using a custom protocol that selects a format not in the enum.","solutions":["Import TransferFormat from @microsoft/signalr and pass TransferFormat.Text or TransferFormat.Binary explicitly rather than magic numbers or strings.","If reading the format from config, map it: const fmt = value === 'binary' ? TransferFormat.Binary : TransferFormat.Text before passing it on.","Confirm the protocol you selected supports the chosen format (JSON hub protocol -> Text; MessagePack -> Binary)."],"exampleFix":"// before\ntransport.connect(url, 'text', {}); // 'text' is not in TransferFormat\n\n// after\nimport { TransferFormat } from '@microsoft/signalr';\ntransport.connect(url, TransferFormat.Text, {});","handlingStrategy":"type-guard","validationCode":"import { TransferFormat } from '@microsoft/signalr';\n\nfunction asTransferFormat(v: unknown): TransferFormat {\n  if (v === TransferFormat.Text || v === TransferFormat.Binary) return v;\n  throw new Error(`Unsupported transfer format: ${String(v)}`);\n}\n\nconst fmt = asTransferFormat(config.format);","typeGuard":"import { TransferFormat } from '@microsoft/signalr';\n\nfunction isTransferFormat(v: unknown): v is TransferFormat {\n  return v === TransferFormat.Text || v === TransferFormat.Binary;\n}","tryCatchPattern":"try {\n  await connection.start(TransferFormat.Text);\n} catch (e) {\n  if (e instanceof Error && /Unknown .* value/.test(e.message)) {\n    // pick a supported TransferFormat value\n  } else throw e;\n}","preventionTips":["Always import TransferFormat and pass the enum member, not a string or magic number.","Map config strings to the enum at the configuration boundary.","Match the format to the hub protocol (JSON->Text, MessagePack->Binary)."],"tags":["signalr","typescript","argument-validation","enum","transport"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}