facebook/relay · error

Did not find item with data id ${__id} in the store.

Error message

Did not find item with data id ${__id} in the store.

What it means

After reading `__id` from an assigned item, Relay looks up that data ID in the record source proxy backing the updater. This error fires when the id exists on the item but no record with that id is present in the store, so the linked record cannot be set.

Source

Thrown at packages/relay-runtime/mutations/createUpdatableProxy.js:229

      throw new Error(
        'Do not assign null to plural linked fields; assign an empty array instead.',
      );
    } else {
      const recordProxies = newValue.map((item): ?RecordProxy => {
        if (item == null) {
          throw new Error(
            'When assigning an array of items, none of the items should be null or undefined.',
          );
        }
        const {__id} = item;
        if (__id == null) {
          throw new Error(
            'The __id field must be present on each item passed to the setter. This indicates a bug in Relay.',
          );
        }
        const newValueRecord = recordSourceProxy.get(__id);
        if (newValueRecord == null) {
          throw new Error(
            `Did not find item with data id ${__id} in the store.`,
          );
        }
        return newValueRecord;
      });
      updatableProxyRootRecord.setLinkedRecords(
        recordProxies,
        selection.name,
        newVariables,
      );
    }
  };
}

function createSetterForSingularLinkedField(
  selection: ReaderLinkedField,
  variables: Variables,
  updatableProxyRootRecord: RecordProxy,

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Ensure the record exists before assigning: create it via `store.get(id)` / `store.create(id, typeName)` in the same updater
  2. Verify you are reading ids from the same store/source the updater operates on
  3. Check that another handler isn't deleting or GC-ing the record before this updater runs
  4. Log the missing id and search the store (`store.get(id)`) to see why it is absent

Example fix

// before
updatable.viewer.friends.set([externalRecord]); // id not in this store
// after
const rec = store.get(externalRecord.__id) ?? store.create(externalRecord.__id, 'User');
updatable.viewer.friends.set([rec]);
Defensive patterns

Strategy: validation

Validate before calling

function requireRecord(store, id) {
  const rec = store.get(id);
  if (rec == null) throw new Error(`Record ${id} not in store before assignment`);
  return rec;
}

Try / catch

try {
  field.set(items);
} catch (e) {
  if (e.message.includes('Did not find item with data id')) {
    const id = /data id (.+?) in/.exec(e.message)?.[1];
    field.set(items.map(i => store.get(i.__id) ?? store.create(i.__id, 'Node')));
  } else throw e;
}

Prevention

When it happens

Trigger: Passing an item whose `__id` refers to a record that was never written to the store (e.g. an id from another RecordSource, an optimistic record not yet committed, or a garbage-collected record).

Common situations: Optimistic updaters referencing records created only after server response; records removed by an earlier updater or GC; ids from a disconnected store/normalized cache.

Related errors


AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02). Data as JSON: /api/errors/25852890fecf2cb7. Report an issue: GitHub.