deepseek-ai/deepseek-harness · error · Error

session event " " is not surface-eligible and cannot carry…

Error message

session event "${event.type}" is not surface-eligible and cannot carry surfaceOp

What it means

Invariant guard in surfaceOpOf: an event whose type is not surface-eligible carries a surfaceOp field. Only surface-eligible event types may carry surface operations; the presence of surfaceOp on any other type means the event was constructed by code that mislabels it, since typed constructors never set it.

Solutions

  1. Remove the surfaceOp field from the non-eligible event
  2. Emit the operation on a surface-eligible event type instead
  3. If constructing events by hand, use the typed event factories which enforce eligibility
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core/session/src/surface.ts:189 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/0dc2bf79097e739a. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/session/src/surface.ts:189

/** Whether a runtime value is the exact positional-replacement shape. */
function isReplaceOp(value: object): value is Extract<SurfaceOp, { op: 'replace' }> {
  const op = value as Record<string, unknown>
  return Object.keys(op).length === 3
    && Object.hasOwn(op, 'op')
    && Object.hasOwn(op, 'start')
    && Object.hasOwn(op, 'end')
    && op['op'] === 'replace'
    && isEventSeq(op['start'])
    && isEventSeq(op['end'])
}

/** Validate event-local surface eligibility and return its operation. */
function surfaceOpOf(event: SessionEvent): SurfaceOp | undefined {
  const raw = event as SessionEvent & { surfaceOp?: unknown; sourceEventSeqs?: unknown }
  if (!isSurfaceEligibleType(event.type)) {
    if (raw.surfaceOp !== undefined) {
      throw new Error(`session event "${event.type}" is not surface-eligible and cannot carry surfaceOp`)
    }
    if (raw.sourceEventSeqs !== undefined) {
      throw new Error(`session event "${event.type}" is not surface-eligible and cannot carry sourceEventSeqs`)
    }
    return
  }
  const op = raw.surfaceOp
  if (op === undefined) {
    throw new Error(`session event "${event.type}" is surface-eligible and requires a surfaceOp marker`)
  }
  if (op === 'append') return op
  if (op === null || typeof op !== 'object' || Array.isArray(op)) {
    throw new Error(`session event "${event.type}" carries an invalid surfaceOp`)
  }
  if (!isReplaceOp(op)) {
    throw new Error(`session event "${event.type}" carries an invalid replace surfaceOp`)
  }
  return op

View on GitHub (pinned to b150a551b8)