dotnet/aspnetcore · error · Error

errorMessage

Error message

errorMessage

What it means

Generic not-empty-string assertion thrown by JsonHubProtocol._assertNotEmptyString. It is invoked from _isInvocationMessage (for `target` and, when present, `invocationId`) and reused across the other validators. The thrown message is whatever the caller passed as `errorMessage` (e.g. "Invalid payload for Invocation message."), so this entry covers the assertion helper itself — any time a hub message field expected to be a non-empty string is missing, empty, or non-string.

Source

Thrown at src/SignalR/clients/ts/signalr/src/JsonHubProtocol.ts:135

        this._assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
    }

    private _isAckMessage(message: AckMessage): void {
        if (typeof message.sequenceId !== 'number') {
            throw new Error("Invalid SequenceId for Ack message.");
        }
    }

    private _isSequenceMessage(message: SequenceMessage): void {
        if (typeof message.sequenceId !== 'number') {
            throw new Error("Invalid SequenceId for Sequence message.");
        }
    }

    private _assertNotEmptyString(value: any, errorMessage: string): void {
        if (typeof value !== "string" || value === "") {
            throw new Error(errorMessage);
        }
    }
}

View on GitHub (pinned to 3600ca084e)

Solutions

  1. Ensure every Invocation message includes a non-empty string `target` (the hub method name).
  2. When invocationId is used, make it a non-empty string.
  3. Verify protocol compatibility and that no proxy strips these fields.
Defensive patterns

Strategy: type-guard

Validate before calling

function validInvocation(m: any): boolean {
  if (typeof m.target !== "string" || m.target === "") return false;
  if (m.invocationId !== undefined && (typeof m.invocationId !== "string" || m.invocationId === "")) return false;
  return true;
}

Type guard

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

Prevention

When it happens

Trigger: An Invocation message with an empty/missing/non-string `target`, or an Invocation message that includes an `invocationId` which is empty or non-string. The helper fires whenever `typeof value !== "string" || value === ""`.

Common situations: Server invokes a client method without a target name, a serializer drops the target field, or a malformed/injected hub message is parsed. Most often a protocol-version mismatch or a hand-rolled server.

Related errors


AI-assisted analysis of dotnet/aspnetcore@3600ca084e (2026-08-11). Data as JSON: /api/errors/34f71f6cbad59d6e. Report an issue: GitHub.