{"record":{"id":"4c3bd6c70ba3cbfe","repo":"facebook/relay","slug":"relay-received-a-field-error-in-the-server-respon","errorCode":null,"errorMessage":"Relay: Received a field error in the server response for field '${fieldError.fieldPath}' in '${fieldError.owner}'. Message: ${fieldError.error.message}","messagePattern":"Relay: Received a field error in the server response for field '(.+?)' in '(.+?)'\\. Message: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/relay-runtime/util/handlePotentialSnapshotErrors.js","lineNumber":52,"sourceCode":"    // passing the event through.\n\n    environment.relayFieldLogger({\n      // the uiContext on fieldError undefined *always*,\n      ...fieldError,\n      // and this is where we assign loggingContext to uiContext to populate it\n      uiContext: loggingContext,\n    });\n  }\n\n  for (const fieldError of fieldErrors) {\n    if (eventShouldThrow(fieldError)) {\n      switch (fieldError.kind) {\n        case 'relay_resolver.error':\n          throw new Error(\n            `Relay: Resolver error at path '${fieldError.fieldPath}' in '${fieldError.owner}'. Message: ${fieldError.error.message}`,\n          );\n        case 'relay_field_payload.error':\n          throw new Error(\n            `Relay: Received a field error in the server response for field '${fieldError.fieldPath}' in '${fieldError.owner}'. Message: ${fieldError.error.message}`,\n          );\n        case 'missing_expected_data.throw':\n          throw new Error(\n            `Relay: Missing expected data at path '${fieldError.fieldPath}' in '${fieldError.owner}'. See https://relay.dev/docs/next/debugging/why-null/ for likely causes.`,\n          );\n        case 'missing_required_field.throw': {\n          let reason: string;\n          if (fieldError.fieldValue === null) {\n            reason =\n              fieldError.fieldError != null\n                ? `the server returned null with an error: ${fieldError.fieldError.message}`\n                : 'the server returned null';\n          } else {\n            reason =\n              'the field was missing in the store (data may not have been fetched, or was removed by a graph relationship change: https://relay.dev/docs/next/debugging/why-null/#graph-relationship-change)';\n          }\n          throw new Error(","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/packages/relay-runtime/util/handlePotentialSnapshotErrors.js#L34-L70","documentation":"handleFieldErrors throws for 'relay_field_payload.error' events: the server response itself contained an error for a field (typical GraphQL errors array with data:null paths), and Relay is surfacing it when the snapshot/error disposition requests throwing. The message carries the field path, owner operation, and server message.","triggerScenarios":"A GraphQL response includes field-level errors (e.g. non-null field resolution failure server-side) while reading data whose event disposition is throw (e.g. @throwOnFieldError, or missing_expected_data.throw style policies on the read).","commonSituations":"Server-side resolver failures for nullable/non-null fields; network layer returning partial data plus errors; tests simulating error responses; missing error handling on the network layer that would otherwise normalize errors.","solutions":["Fix or tolerate the server field error — check fieldPath to see which field failed and handle nulls in the fragment","Wrap the query in an ErrorBoundary / catch around environment.lookup and render a fallback","Adjust the throw disposition (remove @throwOnFieldError) so the error is logged via relayFieldLogger instead of thrown","Update the server resolver or schema so the field doesn't error for this query shape"],"exampleFix":"// before\nconst data = useLazyLoadQuery(Query, vars); // throws on field payload error\n// after\n<ErrorBoundary fallback={<ErrorView/>}>\n  <ComponentUsingQuery/>\n</ErrorBoundary>","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const data = useLazyLoadQuery(Query, vars);\n} catch (e) {\n  if (String(e.message).startsWith('Relay: Received a field error')) {\n    return <FieldErrorView error={e}/>;\n  }\n  throw e;\n}","preventionTips":["Render queries inside Relay ErrorBoundary components","Make nullable fields nullable in the schema where errors are expected","Handle partial data (nulls) in fragments defensively","Inspect fieldPath in the message to coordinate with backend owners"],"tags":["relay","graphql","server-error","field-error","snapshot"],"backgroundTag":"resolver-field-error","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}