Error: applyIncrementalJson cannot change Model properties

Hi,

I try to put the diagram into mendix, but it return :

Error: applyIncrementalJson cannot change Model properties
at B (go.js:12)
at ar…/…/gojs/release/go.js.t.Cq (go.js:1803)
at ar…/…/gojs/release/go.js.t.yx (go.js:1736)
at GojsDiagram…/…/react-gojs/dist/GojsDiagram.js.GojsDiagram.applyUpdatesFromModel (GojsDiagram.js:149)
at GojsDiagram…/…/react-gojs/dist/GojsDiagram.js.GojsDiagram.componentDidUpdate (GojsDiagram.js:67)
at za (mxui.js?637152267363462068:55)
at Ha (mxui.js?637152267363462068:55)
at mxui.js?637152267363462068:55
at Object.t.unstable_runWithPriority (mxui.js?637152267363462068:73)
at Ps (mxui.js?637152267363462068:55)

1 Like

That message is saying that some model properties do not match the values provided in the argument to Model.applyIncrementalJson.

An obvious example is the Model.nodeKeyProperty. If the model being modified assumes the node data key is named “A”, but the JSON text being applied assumes the node data key is named “B”, clearly there is something wrong.

The assumption is that Model.toIncrementalJson produced what is being passed to Model.applyIncrementalJson. Apparently some model property (or properties) have changed value since it was written out.

Hi Walter, I am getting this same error message running my model.

The error is occuring when I set the state of my diagram component to update the model (I’m using react):

Oddly though, the model works perfectly fine when I run my app locally, but when I go to deploy my application (using docker), I hit this issue running the app inside the container. I’m assuming it must be a docker issue, but any thoughts on what could be happening?

Thanks,

One thing I am doing is creating my own layout so perhaps the model properties then differ somehow? I create my own class which extends layered digraph layout, overwrite 2 of the methods, and then use that as my layout.

I don’t know why it would work fine locally though if this is the case…

Layout has nothing to do with models.

It would be useful to see some data. Could you show the first few lines of the result of calling Model.toJson, and the first few lines of the JSON-formatted text that you are passing to Model.applyIncrementalJson?

Ahh okay. Just thought I’d include it because the layout calls model.setDataProperty().

Sure, I’m using react’s setState method and passing a model with:

  1. linkDataArray = an array of links containing
{
            "from":"Node1", 
            "to":"Node2"
}
  1. nodeDataArray = array of nodes containing
 {
            "id": "1",
            "key": "nameOfNode",
            "difficulty": "2",
            "is_milestone": true,
            "is_locked": false,
}

as well as 1 array entry for my forced bands using your code from this example with

{
             "key": "_BANDS",
             "category": "Bands",
             "itemArray": [{}, {}, {}, {}, {}, {}, {}, {}]
}

Running model.toJson produces

{
            "class": "GraphLinksModel",
            "nodeDataArray": [],
            "linkDataArray": []
}

which is blank I believe because the diagram creates before the initial fetch returns data to update the model

Could you show the first few lines of the string you are passing to Model.applyIncrementalJson?