Solution for A fatal error occured during client reset: 'Requested index 2 calling get() on set 'myschema.arrayfield' when max is 1'


I’m facing this error Server permissions for this file ident have changed since the last time it was used (IDENT) (1) when a usercustom data that is used in the permission roles is updated, which should handled by a ClientReset. But the problem is when client reset is triggered, I get an error when realm tries to perform the client reset. The error is A fatal error occured during client reset: 'Requested index 2 calling get() on set 'anotherschema.arrayfield' when max is 1' (2).

The permission rule that uses the usercustom data is "document_filters": { "read": { "roomId": { "$in": "%%user.custom_data.rooms" } }, ... }

The first error itself shouldn’t be a problem, since it will only cause a ClientReset, which is expected, but then while doing the client reset, the second error that doesn’t seem to make any sense to me. The error is in another schema that has nothing to do with any of the changes done, which is why I don’t really understand the error. I tried to find any part of the code trying to access anotherschema.arrayfield by index, but I’m guessing this is an internal code of realm initiateClientReset.

This is my client reset handler:

onError: async (session, error) => {
   if ( === "ClientReset" && realm) {
      const realmPath = realm.path;
      Realm.App.Sync.initiateClientReset(app, realmPath);

I would appreciate any help on this matter, I did find similar people with this error, but could only find people with the first error, but not the second.

After some more debugging I found out that the issue it’s because anotherschema.arrayfield is a relationship field, and the array has an ObjectId from a object that doesn’t exist anymore.

It’s still weird how this error is shown, since login and sync works fine with this, but once it tries to perform a ClientReset it will throw this error. Ideally realm would handle non-existing relationships, or at least throw an error when this happens with a more meaningful message. I would imagine something like A fatal error occurred during client reset: Relationship object not found at schema.field. Either way, thanks for all the support :slight_smile: .

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.