Realm Schema Confusion

I’ve been trying to use a RealmList as a type of ‘images’ field in the schema. Been struggling for a while now, because I’ve been getting this error, which does not make any sense, since I think I’ve setup everything correctly. Please read down below.

ending session with error: non-breaking schema change: adding schema for Realm table “Diary”, schema changes from clients are restricted when developer mode is disabled (ProtocolErrorCode=225)

My schema:

{
  "title": "Diary",
  "bsonType": "object",
  "required": [
    "_id",
    "ownerId",
    "mood",
    "title",
    "description",
    "images",
    "date"
  ],
  "properties": {
    "_id": {
      "bsonType": "objectId"
    },
    "ownerId": {
      "bsonType": "string"
    },
    "mood": {
      "bsonType": "string"
    },
    "title": {
      "bsonType": "string"
    },
    "description": {
      "bsonType": "string"
    },
    "images": {
      "bsonType": "array",
      "items": {
        "bsonType": "string"
      }
    },
    "date": {
      "bsonType": "date"
    }
  }
}

My model class:

open class Diary : RealmObject {
    @PrimaryKey
    var _id: ObjectId = ObjectId.create()
    var ownerId: String = ""
    var mood: String = Mood.Neutral.name
    var title: String = ""
    var description: String = ""
    var images: RealmList<String> = realmListOf()
    var date: RealmInstant = RealmInstant.from(System.currentTimeMillis(), 0)
}

I don’t see anything incompatible here, the problem is with that ‘images’ field. Somehow the model class does not seem to be correct, based on the schema I’ve defined. And yes I’ve tried using a development mode to generate the schema automatically from the client. But with that I’ve generated a schema where that ‘images’ field was “NOT” a required field…and I don’t know why?

Plus that error log above does not provide any useful information, about what should I do to fix the issue. It’s not even telling me the name of the field. I think that should also be fixed.

Hi. So the issue you are running into is that lists cannot be required. We are working on better alerting / UX around this sort of thing but the idea is that the list is implicitly always initialized so it doesn’t matter for the purposed of the JSON Schema. Given that you are just developing I would delete this schema from the App Service UI and then re-upload your schema using dev mode and it should work fine.

1 Like

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