{"record":{"id":"e1a3be807b73a00b","repo":"facebook/relay","slug":"the-id-field-must-be-present-on-each-item-passed","errorCode":null,"errorMessage":"The __id field must be present on each item passed to the setter. This indicates a bug in Relay.","messagePattern":"The __id field must be present on each item passed to the setter\\. This indicates a bug in Relay\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/relay-runtime/mutations/createUpdatableProxy.js","lineNumber":223,"sourceCode":"  updatableProxyRootRecord: RecordProxy,\n  recordSourceProxy: RecordSourceProxy,\n) {\n  return function set(newValue: ReadonlyArray<{__id: string, ...}>) {\n    const newVariables = getArgumentValues(selection.args ?? [], variables);\n    if (newValue == null) {\n      throw new Error(\n        'Do not assign null to plural linked fields; assign an empty array instead.',\n      );\n    } else {\n      const recordProxies = newValue.map((item): ?RecordProxy => {\n        if (item == null) {\n          throw new Error(\n            'When assigning an array of items, none of the items should be null or undefined.',\n          );\n        }\n        const {__id} = item;\n        if (__id == null) {\n          throw new Error(\n            'The __id field must be present on each item passed to the setter. This indicates a bug in Relay.',\n          );\n        }\n        const newValueRecord = recordSourceProxy.get(__id);\n        if (newValueRecord == null) {\n          throw new Error(\n            `Did not find item with data id ${__id} in the store.`,\n          );\n        }\n        return newValueRecord;\n      });\n      updatableProxyRootRecord.setLinkedRecords(\n        recordProxies,\n        selection.name,\n        newVariables,\n      );\n    }\n  };","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/packages/relay-runtime/mutations/createUpdatableProxy.js#L205-L241","documentation":"Each item passed to a plural linked field setter must be a record proxy exposing a `__id` (data ID). This error fires when an item lacks `__id`, and Relay states it indicates a bug in Relay itself, since proxies returned by the library always carry it.","triggerScenarios":"Passing raw plain objects (fetched manually or constructed inline) instead of RecordProxies from the updatable proxy into `pluralField.set(...)` — such objects have no `__id` property.","commonSituations":"Assigning raw mutation response objects instead of records read from the same updatable proxy; mixing records from a different RecordSource; a Relay internals regression.","solutions":["Only pass records obtained from the updatable proxy (e.g. `updatable.viewer.friends.get()[0]`) or existing linked records into the setter","Read the target records from `store.get(id)`/`recordSourceProxy.get(id)` rather than using raw response payloads","If items come from another source, copy their fields into store records first, then assign those records","If you are passing valid RecordProxies and still see this, file a bug with Relay — the message signals an internal invariant"],"exampleFix":"// before\nupdatable.viewer.friends.set(response.updateUser.friends); // raw payload objects\n// after\nconst updated = updatable.viewer.friends.get();\nupdatable.viewer.friends.set(updated); // record proxies from the store","handlingStrategy":"type-guard","validationCode":"function isRecordProxyLike(item) {\n  return item != null && typeof item === 'object' && typeof item.__id === 'string' && item.__id.length > 0;\n}\nitems.forEach(item => { if (!isRecordProxyLike(item)) throw new TypeError('Setter requires store record proxies with __id'); });","typeGuard":"function isRecordProxy(item: unknown): item is {__id: string} {\n  return typeof item === 'object' && item !== null && typeof (item as any).__id === 'string';\n}","tryCatchPattern":"try {\n  field.set(items);\n} catch (e) {\n  if (e.message.includes('__id field must be present')) throw new Error('Pass record proxies from the updatable proxy/store, not raw payload objects', {cause: e});\n  throw e;\n}","preventionTips":["Only assign records obtained from the updatable proxy, store.get, or existing linked records","Never assign raw mutation/query response payloads directly","Copy raw payload fields into store records first, then link those","If valid proxies trigger this, file a Relay bug — it is an internal invariant"],"tags":["relay","updater","graphql","internal-bug"],"backgroundTag":"missing-data-id","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}