diegosouzapw/OmniRoute · error · ClaudeWebProtocolError

Content delta text is invalid

Error message

Content delta text is invalid

What it means

Shape guard deltaText: none of the candidate text fields on a content_block delta (e.g. text/thinking fields per the passed field list) holds a string. The delta event arrived but carries its text payload in an unrecognized shape, so no text can be extracted for the chunk.

Solutions

  1. Log the raw delta to see which field now carries the text and extend the fields list
  2. Emit an empty/neutral delta rather than killing the stream when only one delta is affected
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at open-sse/executors/claude-web/stream.ts:191 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/0d4397d65c5cfd06. Report an issue: GitHub.

Appendix: source

Thrown at open-sse/executors/claude-web/stream.ts:191

  if (!value || typeof value !== "object" || Array.isArray(value)) {
    throw new ClaudeWebProtocolError(`${context} must be an object`);
  }
  return value as Record<string, unknown>;
}

function requireBlockIndex(event: Record<string, unknown>): number {
  if (!Number.isInteger(event.index) || (event.index as number) < 0) {
    throw new ClaudeWebProtocolError("Content block index is invalid");
  }
  return event.index as number;
}

function deltaText(delta: Record<string, unknown>, fields: string[]): string {
  for (const field of fields) {
    const value = delta[field];
    if (typeof value === "string") return value;
  }
  throw new ClaudeWebProtocolError("Content delta text is invalid");
}

function thinkingSummaryText(delta: Record<string, unknown>): string {
  if (typeof delta.summary === "string") return delta.summary;
  if (delta.summary && typeof delta.summary === "object" && !Array.isArray(delta.summary)) {
    return deltaText(delta.summary as Record<string, unknown>, ["summary", "text", "thinking"]);
  }
  return deltaText(delta, ["text", "thinking"]);
}

interface ProtocolState {
  phase: StreamPhase;
  openBlocks: Map<number, BlockKind>;
  toolBlocks: Map<number, ToolBlockInfo>;
  stopReason: string;
}

function protocolFailure(state: ProtocolState, message: string): never {

View on GitHub (pinned to a179ffed5b)