dotnet/aspnetcore · error · Error
Unknown value: .
Error message
Unknown ${name} value: ${val}. What it means
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.
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).
Example fix
// before
transport.connect(url, 'text', {}); // 'text' is not in TransferFormat
// after
import { TransferFormat } from '@microsoft/signalr';
transport.connect(url, TransferFormat.Text, {}); Defensive patterns
Strategy: type-guard
Validate before calling
import { TransferFormat } from '@microsoft/signalr';
function asTransferFormat(v: unknown): TransferFormat {
if (v === TransferFormat.Text || v === TransferFormat.Binary) return v;
throw new Error(`Unsupported transfer format: ${String(v)}`);
}
const fmt = asTransferFormat(config.format); Type guard
import { TransferFormat } from '@microsoft/signalr';
function isTransferFormat(v: unknown): v is TransferFormat {
return v === TransferFormat.Text || v === TransferFormat.Binary;
} Try / catch
try {
await connection.start(TransferFormat.Text);
} catch (e) {
if (e instanceof Error && /Unknown .* value/.test(e.message)) {
// pick a supported TransferFormat value
} else throw e;
} Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Message is incomplete.
- The ' ' argument is required.
- The ' ' argument should not be empty.
- Unknown transport: .
- A valid url is required.
AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11).
Data as JSON: /api/errors/ecc0ee84b090f9d5.
Report an issue: GitHub.
Appendix: source
Thrown at src/SignalR/clients/ts/signalr/src/Utils.ts:32
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";
}
// WebWorkers don't have a window object so the isBrowser check would fail
public static get isWebWorker(): boolean {
return !Platform.isNode && typeof self === "object" && "importScripts" in self;
}
// react-native has a window but no document
static get isReactNative(): boolean {View on GitHub (pinned to 3600ca084e)