realm / realm-object-server

Tracking of issues related to the Realm Object Server and other general issues not related to the specific SDK's
https://realm.io
293 stars 42 forks source link

"Invalid realm type" error after ROS migration. #374

Closed molind closed 6 years ago

molind commented 6 years ago

I've just upgraded ROS from 2.7.2 to 3.4.2. And now it becomes interesting. Our users can't open their synced realms because of error.

    [RLMSyncManager sharedManager].errorHandler = ^(NSError *error, RLMSyncSession *session) {
        LogError(@"RLMSyncManager error %@", error);
    };

RLMSyncManager returns Error Domain=io.realm.sync Code=8 "(null)" UserInfo={underlying_error=Error Domain=io.realm.sync.auth Code=3 "(null)" UserInfo={statusCode=400}}

And that's fine seems something with our auth credentials on server. But server log tells me: HTTP response: be33008a-ae5e-4fa1-bab2-f11b40f11b55 {"type":"https://realm.io/docs/object-server/problems/invalid-realm-type","title":"The type of the Realm file was invalid.","status":400,"code":619}

Which is basically You're trying to open partial file with non partial configuration. But client and server uses same full realms. And no modifications happened.

Seems this error returned as false positive.

I've tried to grand administrator permission to that user. It could open his database. But as soon I remove admin permission it sees same error chain.

New users is not affected by this migration issue.

Is there anything I could do to let my users connect to their data?

Goals

Open synchronized realm

Expected Results

It should open

Actual Results

Server returns HTTP response: be33008a-ae5e-4fa1-bab2-f11b40f11b55 {"type":"https://realm.io/docs/object-server/problems/invalid-realm-type","title":"The type of the Realm file was invalid.","status":400,"code":619}

Steps to Reproduce

I could send you user folder from our server or any part of server log.

Version of Realm and Tooling

Logs

cat /var/log/realm-object-server.log Open files in Realm Object Server: {"regular":277,"directory":0,"character-device":1,"block-device":0,"pipe":18,"symbolic-link":0,"socket":143,"unknown":8,"total":447} 4:38:33 PM HTTP response: 1d11b856-c059-400a-886b-f27b9cd92578 {"type":"https://realm.io/docs/object-server/problems/invalid-realm-type","title":"The type of the Realm file was invalid.","status":400,"code":619}
ianpward commented 6 years ago

@molind Can you open Studio and connect to the ROS and then do View> Show System Realms. Then open the /__admin realm and go to the RealmFile class. Find your Realm and change the type to full or reference if you are using partial sync.

nirinchev commented 6 years ago

This should have been fixed with ROS 3.4.3. Can you double check that this is the version that is running on your server? If you go to node_modules/realm-object-server/dist/services/AuthService.js, there should be a function ensureRealmOfType with the following body:

static ensureRealmOfType(requiredType, actualType) {
    if (!(actualType in realms_1.RealmType)) {
        actualType = realms_1.RealmType.full;
    }
    if (actualType !== requiredType) {
        throw new errors.realm.InvalidRealmType(requiredType, actualType);
    }
}
molind commented 6 years ago

@ianpward Checked it. realmType was empty for all realms.

@nirinchev Yes, indeed. I used 3.4.2, and now after upgrade to 3.4.3 everything works fine, thanks!

hakobvardanyan commented 6 years ago

Hi everyone ;)

https://stackoverflow.com/questions/51875783/session-error-the-type-of-the-realm-file-was-invalid What reason can it be people?

hakobvardanyan commented 6 years ago

default