Schema validation failed: property 'MatchFormSettingsSchema.questionsArray' of type 'array' has unknown object type 'Question'

Hello, I’m trying to setup sync with a new Schema called MatchFormSettingsSchema. This is the code for that schema:

@RealmModel()
class _MatchFormSettingsSchema {
  @PrimaryKey()
  @MapTo('_id')
  late ObjectId id;

  late List<_Question> questionsArray;
}


@RealmModel(ObjectType.embeddedObject)
class _Question {
  late String input;

  late String type;
}

However when initializing my flutter App I get this error while creating my Realm Object:


  final appConfig = AppConfiguration(appID);
  final app = App(appConfig);

  final user = await app.logIn(Credentials.anonymous());
  final realmConfig = Configuration.flexibleSync(
    user,
    [
      MatchSchema.schema,
      MatchFormSettingsSchema.schema,

    ],
  );

  late Realm realm;
  if (await isDeviceOnline()) {
    realm = await Realm.open(realmConfig);
  } else {
    realm = Realm(realmConfig);
  }

Error:

Exception has occurred.
RealmException: Message: Schema validation failed due to the following errors:
- Property 'MatchFormSettingsSchema.questionsArray' of type 'array' has unknown object type 'Question')

Hi @Juan_Pablo_Gutierrez,

Could you please also share the schema you have defined in your App Services App on the Atlas Portal? Alternatively, you can also share the App ID, and/or send it with a direct message, so that we could check.

At a first glance:

You didn’t include Question there: you can either add it, or just avoid to define a schema list altogether, so that Realm will figure it out by itself.

Thanks for answering, it was in fact that I was not defining the Question Schema.

Thanks!

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