Skip to content

UnknownEvent is not a member of the Event union (second half of #1572 never landed) #1696

Description

@ccclapon

What we found

UnknownEvent is declared in src/common/interfaces/event.interface.ts (line 1015 on main today) but it is not a member of the exported Event union, and there is no UnknownEventResponse in the EventResponse union. The default branch of deserializeEvent in src/common/serializers/event.serializer.ts papers over the gap with a cast:

default:
  return {
    ...eventBase,
    event: (event as { event: string }).event,
    data: (event as { data: Record<string, unknown> }).data,
  } as Event;

Effect

The cast hides the case from the compiler. A consumer that writes an exhaustive switch over event.event with an assertNever default compiles clean and throws at runtime on the first event type the SDK does not know. The Event union always trails the API, so this eventually happens to every such consumer.

Request

  • Add | UnknownEvent to the Event union.
  • Add an UnknownEventResponse interface and include it in the EventResponse union.

History

#1572 reported exactly this as its second item. It was closed as completed, but only the first item (abort signal plumbing) landed; the union is unchanged on main. The same class of failure keeps recurring with a different missing event type each time: #864, #1360, #1362, #1453, and #1685 (open). A typed UnknownEvent member turns each of those from a runtime failure into a compiler message.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions