{"record":{"id":"9bca94edb6880da5","repo":"ReactiveX/rxjs","slug":"unexpected-notification-kind-kind","errorCode":null,"errorMessage":"Unexpected notification kind ${kind}","messagePattern":"Unexpected notification kind (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/rxjs/src/notification.ts","lineNumber":63,"sourceCode":"    } else {\n      complete?.();\n    }\n  }\n\n  accept(observer: Partial<Observer<T>>): void;\n  accept(next: (value: T) => void, error?: (error: any) => void, complete?: () => void): void;\n  accept(nextOrObserver: Partial<Observer<T>> | ((value: T) => void), error?: (error: any) => void, complete?: () => void): void {\n    if (typeof nextOrObserver === 'object' && nextOrObserver !== null) {\n      this.observe(nextOrObserver);\n    } else {\n      this.do(nextOrObserver, error, complete);\n    }\n  }\n\n  toObservable(): Observable<T> {\n    const { kind, value, error } = this;\n    if (kind !== 'N' && kind !== 'E' && kind !== 'C') {\n      throw new TypeError(`Unexpected notification kind ${kind}`);\n    }\n\n    return new Observable<T>((subscriber) => {\n      if (kind === 'N') {\n        subscriber.next(value as T);\n        subscriber.complete();\n      } else if (kind === 'E') {\n        subscriber.error(error);\n      } else {\n        subscriber.complete();\n      }\n    });\n  }\n\n  private static readonly completeNotification = new Notification('C') as Notification<never> & CompleteNotification;\n\n  static createNext<T>(value: T): Notification<T> & NextNotification<T> {\n    return new Notification('N', value) as Notification<T> & NextNotification<T>;","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/ReactiveX/rxjs/blob/54796b38a57e6309f9861e174737479bb3f63f61/packages/rxjs/src/notification.ts#L45-L81","documentation":"Notification.toObservable() validates that the notification's kind is one of 'N', 'E', 'C' before building an Observable. A notification object with any other kind (or a mutated/custom kind) is not a valid ObservableNotification and throws a TypeError.","triggerScenarios":"new Notification('X' as any, value).toObservable(), or calling toObservable() on a hand-rolled object {kind: 'n', value} (lowercase kind from a serialization round-trip).","commonSituations":"Notifications deserialized from JSON where the kind casing was lost, or third-party code constructing Notification-like objects with non-standard kinds.","solutions":["Normalize kinds to uppercase 'N'/'E'/'C' before calling toObservable","Use the factory helpers nextNotification(), errorNotification(), completeNotification() instead of constructing Notification manually","Add a type guard on kind before conversion"],"exampleFix":"// before\nconst n = JSON.parse(json); // {kind: 'n', value: 1}\nn.toObservable?.(); // throws\n// after\nconst n = JSON.parse(json);\nif (n.kind) n.kind = n.kind.toUpperCase();\nNotification.prototype.toObservable.call(n);","handlingStrategy":"type-guard","validationCode":"const kind = notification.kind;\nif (kind !== 'N' && kind !== 'E' && kind !== 'C') throw new TypeError('bad kind');\nnotification.toObservable();","typeGuard":"function isValidNotification(n: { kind?: unknown }): n is ObservableNotification<any> {\n  return n.kind === 'N' || n.kind === 'E' || n.kind === 'C';\n}","tryCatchPattern":null,"preventionTips":["Build notifications via nextNotification/errorNotification/completeNotification","Uppercase kinds after JSON deserialization","Type notification payloads as ObservableNotification<T>"],"tags":["notification","validation","serialization","rxjs-next"],"backgroundTag":"invalid-notification-kind","analyzedSha":"54796b38a57e6309f9861e174737479bb3f63f61","analyzedAt":"2026-08-28T10:21:27.410Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}