can1357/oh-my-pi · error · TypeError
event_type is required
Error message
event_type is required
What it means
normalizeEventType requires an event_type string; when the value is undefined a TypeError is thrown before any enum mapping occurs. Event construction and the eventType accessor both route through this normalizer, so undefined event types cannot enter the stream.
Solutions
- Always set event_type to a valid EventType value when constructing events
- Default the field at the boundary: event_type: raw.event_type ?? EventType.MEMORY_ADDED (when a sensible default exists)
- Fix the upstream producer/deserializer so event_type is never dropped
Example fix
// before
stream.publish({ payload }); // event_type undefined
// after
stream.publish({ event_type: EventType.MEMORY_ADDED, payload }); Defensive patterns
Strategy: validation
Validate before calling
if (event.event_type === undefined) {
throw new Error("cannot publish event without event_type");
}
stream.publish(event); Type guard
function hasEventType(event: Partial<StreamEvent>): event is StreamEvent & { event_type: string } {
return typeof event.event_type === "string";
} Try / catch
try {
stream.publish(event);
} catch (err) {
if (err instanceof TypeError && err.message === "event_type is required") {
logger.error("event missing event_type", { keys: Object.keys(event) });
}
throw err;
} Prevention
- Make event_type mandatory in your event-builder helpers
- Default event_type at deserialization boundaries
- Type event payloads so TS flags objects missing event_type
When it happens
Trigger: Creating a streaming event object without an event_type field; calling the eventType accessor on an event lacking that property; spreading partial records where event_type was omitted.
Common situations: Deserializing events from a source that dropped the event_type column/field; constructing event objects manually with only payload fields; optional-field defaults that left event_type undefined instead of a string.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- assistantMessageEvent.content must be a string
- assistantMessageEvent.contentIndex must be an integer
- assistantMessageEvent.delta must be a string
- pluginClass must be a MnemopiPlugin subclass
- queryTime must be null, an ISO date string, or a valid Date
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/725934b8ab909db0.
Report an issue: GitHub.
Appendix: source
Thrown at packages/mnemopi/src/core/streaming.ts:71
readonly importance?: number | null;
readonly metadata?: Record<string, unknown> | null;
readonly delta?: Record<string, unknown> | null;
}
export type MemoryEventDict = {
event_type: string;
memory_id: string;
timestamp: string;
session_id?: string | null;
content?: string | null;
source?: string | null;
importance?: number | null;
metadata?: Record<string, unknown> | null;
delta?: Record<string, unknown> | null;
};
function normalizeEventType(value: string | undefined): EventType {
if (value === undefined) throw new TypeError("event_type is required");
switch (value) {
case EventType.MEMORY_ADDED:
case EventType.MEMORY_RECALLED:
case EventType.MEMORY_INVALIDATED:
case EventType.MEMORY_CONSOLIDATED:
case EventType.MEMORY_UPDATED:
return value;
default: {
const mapped = EventType[value as keyof typeof EventType];
if (mapped !== undefined) return mapped;
throw new RangeError(`Unknown event type: ${value}`);
}
}
}
function isSqlQueryBinding(value: unknown): value is SQLQueryBindings {
return (
value === null ||View on GitHub (pinned to 9690622007)