[FEATURE-13532]OOB Exception when trying to append to a Flex Repeater's prop.instances

I’m trying to use a message handler to add instances to a Flex Repeater. This is what I have in a message handler on the Flex Repeater:

self.props.instances.append( {} )

Here’s the error I’m getting:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 4, in onMessageReceived java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$ArrayWrapper.pyset(PropertyTreeScriptWrapper.java:223) at org.python.core.PyArray.set(PyArray.java:1616) at org.python.core.PyArray.appendUnchecked(PyArray.java:566) at org.python.core.PyArray.array_append(PyArray.java:505) at org.python.core.PyArray$array_append_exposer.__call__(Unknown Source) at org.python.core.PyObject.__call__(PyObject.java:484) at org.python.pycode._pyx312.onMessageReceived$1(:4) at org.python.pycode._pyx312.call_function() at org.python.core.PyTableCode.call(PyTableCode.java:171) at org.python.core.PyBaseCode.call(PyBaseCode.java:308) at org.python.core.PyFunction.function___call__(PyFunction.java:471) at org.python.core.PyFunction.__call__(PyFunction.java:466) at org.python.core.PyFunction.__call__(PyFunction.java:456) at org.python.core.PyFunction.__call__(PyFunction.java:451) at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:776) at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:894) at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:574) at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:87) at com.inductiveautomation.perspective.gateway.model.MessageHandlerCollection$MessageHandlerImpl$1.lambda$invoke$0(MessageHandlerCollection.java:80) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

at org.python.core.Py.JavaError(Py.java:552)

at org.python.core.PyTableCode.call(PyTableCode.java:180)

at org.python.core.PyBaseCode.call(PyBaseCode.java:308)

at org.python.core.PyFunction.function___call__(PyFunction.java:471)

at org.python.core.PyFunction.__call__(PyFunction.java:466)

at org.python.core.PyFunction.__call__(PyFunction.java:456)

at org.python.core.PyFunction.__call__(PyFunction.java:451)

at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:776)

at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:894)

at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:574)

at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:87)

at com.inductiveautomation.perspective.gateway.model.MessageHandlerCollection$MessageHandlerImpl$1.lambda$invoke$0(MessageHandlerCollection.java:80)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException: Traceback (most recent call last): File "", line 4, in onMessageReceived java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$ArrayWrapper.pyset(PropertyTreeScriptWrapper.java:223) at org.python.core.PyArray.set(PyArray.java:1616) at org.python.core.PyArray.appendUnchecked(PyArray.java:566) at org.python.core.PyArray.array_append(PyArray.java:505) at org.python.core.PyArray$array_append_exposer.__call__(Unknown Source) at org.python.core.PyObject.__call__(PyObject.java:484) at org.python.pycode._pyx312.onMessageReceived$1(:4) at org.python.pycode._pyx312.call_function() at org.python.core.PyTableCode.call(PyTableCode.java:171) at org.python.core.PyBaseCode.call(PyBaseCode.java:308) at org.python.core.PyFunction.function___call__(PyFunction.java:471) at org.python.core.PyFunction.__call__(PyFunction.java:466) at org.python.core.PyFunction.__call__(PyFunction.java:456) at org.python.core.PyFunction.__call__(PyFunction.java:451) at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:776) at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:894) at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:574) at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:87) at com.inductiveautomation.perspective.gateway.model.MessageHandlerCollection$MessageHandlerImpl$1.lambda$invoke$0(MessageHandlerCollection.java:80) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) java.lang.ArrayIndexOutOfBoundsException: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

... 17 common frames omitted

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

at com.inductiveautomation.perspective.gateway.script.PropertyTreeScriptWrapper$ArrayWrapper.pyset(PropertyTreeScriptWrapper.java:223)

at org.python.core.PyArray.set(PyArray.java:1616)

at org.python.core.PyArray.appendUnchecked(PyArray.java:566)

at org.python.core.PyArray.array_append(PyArray.java:505)

at org.python.core.PyArray$array_append_exposer.__call__(Unknown Source)

at org.python.core.PyObject.__call__(PyObject.java:484)

at org.python.pycode._pyx312.onMessageReceived$1(:4)

at org.python.pycode._pyx312.call_function()

at org.python.core.PyTableCode.call(PyTableCode.java:171)

... 15 common frames omitted

What seems odd is that if I set the instances using

self.props.instances = [ {} ]

or

self.props.instances = [ {}, {} ]

everything works as expected. Obviously my end goal is to parameterize these instances, but right now I’m just trying to get the instances adding/deleting. Am I missing something or is this a bug?

2 Likes

We have an existing internal ticket to add this and other python-esque functions to our property editor objects, but right now it currently does not work this way.
As a workaround, you can get a list from the instances and append to it using something like:

arr = self.props.instances.tolist()
arr.append({})
self.props.instances = arr
1 Like

self.props.instances = [ {} ]
this is okey ,

but i am passing parameters to flex repeater.
while adding new
self.props.instances = [ {} ] with this i need to pass the parameters.