{"record":{"id":"f6b8d484e4a1ed88","repo":"facebook/relay","slug":"relay-unexpected-event-kind","errorCode":null,"errorMessage":"Relay: Unexpected event kind","messagePattern":"Relay: Unexpected event kind","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/relay-runtime/util/handlePotentialSnapshotErrors.js","lineNumber":101,"sourceCode":"      }\n    }\n  }\n}\n\nfunction eventShouldThrow(event: FieldError): boolean {\n  switch (event.kind) {\n    case 'relay_resolver.error':\n    case 'relay_field_payload.error':\n      return event.shouldThrow && !event.handled;\n    case 'missing_expected_data.throw':\n    case 'missing_required_field.throw':\n      return !event.handled;\n    case 'missing_required_field.log':\n    case 'missing_expected_data.log':\n      return false;\n    default:\n      event.kind as empty;\n      throw new Error('Relay: Unexpected event kind');\n  }\n}\n\nfunction handlePotentialSnapshotErrors(\n  environment: IEnvironment,\n  fieldErrors: ?FieldErrors,\n  loggingContext: unknown | void,\n) {\n  /**\n   * Inside handleFieldErrors, we check for throwOnFieldError - but this fn logs the error anyway by default\n   * which is why this still should run in any case there's errors.\n   */\n  if (fieldErrors != null) {\n    handleFieldErrors(environment, fieldErrors, loggingContext);\n  }\n}\n\nmodule.exports = {","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/packages/relay-runtime/util/handlePotentialSnapshotErrors.js#L83-L119","documentation":"Exhaustiveness guard in eventShouldThrow: a FieldError event arrived whose kind is not one of the known cases (relay_resolver.error, relay_field_payload.error, missing_expected_data.throw/log, missing_required_field.throw/log). It never fires for well-formed Relay internals; it indicates a new or malformed event kind reached the error dispatcher, i.e. version skew or a corrupted record in the store.","triggerScenarios":"Thrown at packages/relay-runtime/util/handlePotentialSnapshotErrors.js:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the Relay runtime version that wrote the FieldError events matches the version reading them","Inspect the persisted record's kind field for unexpected/corrupted values","If you added a new FieldError kind in a fork, extend the switch in eventShouldThrow to handle it"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}