# coreDataToUpdate error when dynamically changing the JSON Schema

**URL:** <https://jsonforms.discourse.group/t/coredatatoupdate-error-when-dynamically-changing-the-json-schema/1428>\
**Category:** General\
**Created:** [April 7, 2023, 4:59pm UTC](https://jsonforms.discourse.group/t/coredatatoupdate-error-when-dynamically-changing-the-json-schema/1428 "2023-04-07T16:59:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kobbejager](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/kobbejager/32/617_2.png) [@kobbejager](https://jsonforms.discourse.group/u/kobbejager)\
**Post date:** [April 7, 2023, 4:59pm UTC](https://jsonforms.discourse.group/t/coredatatoupdate-error-when-dynamically-changing-the-json-schema/1428/1 "2023-04-07T16:59:27Z")

</div>

Hi,

I’m writing a JSON Schema editor component for my vue/vuetify app. My initial JSON Schema has an “$id” property. Whenever I change something in the schema, I get the following error in the console:

```auto
Error in callback for watcher "coreDataToUpdate":
Error: schema with key or id "https://...[redacted]..." already exists

```

If I remove the $id from my schema, the issue is solved. I guess that JsonForms recreates a random id when none is present? Anyway, removing $id from my schema doesn’t seems a bit hackerish. Are there cleaner solutions?

Thanks

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [April 11, 2023, 7:48am UTC](https://jsonforms.discourse.group/t/coredatatoupdate-error-when-dynamically-changing-the-json-schema/1428/2 "2023-04-11T07:48:31Z")

</div>

Hi @kobbejager,

This issue occurs because of our usage of AJV. By default AJV is stateful and caches schemas according to their `$id`. So when another `schema` object with the same `$id` is encountered it throws an error. We already handle most of these cases within the JSON Forms code by removing the schema from the AJV cache before recompiling. We either missed a case or you are using a custom AJV which is already prefilled.

Removing the `$id` before handing the schema over to JSON Forms is certainly fine. An alternative could be to give the JSON Forms component a `key` to reinitialize it whenever your schema changes.
