System.tag.configure Path issues

I’m trying to make several siblings of an already existing UDT instance. I thought the best way to do this would be to use system.tag.getConfiguration to get the configuration, copy the resulting dictionary, modify it, and write a new tag using system.tag.configure. I’m having trouble with the write step. As an example, here is a script and the result on the console.

Does anyone know why I’m getting this error message?

I’m using 8.1.5 for now. I’m actively working on a plan to upgrade, but I have to work with what I have for the moment.

import copy
from com.inductiveautomation.ignition.common.tags.paths import BasicTagPath
sampleConfig = system.tag.getConfiguration(
	'[default]zachTest/dustCollection/airlockA',
	1
)
print type(sampleConfig)
print type(sampleConfig[0])
print type(sampleConfig[0]['path'])
print system.tag.configure('[default]zachTest/dustCollection/',sampleConfig)

newSingle = copy.deepcopy(sampleConfig)
print type(newSingle)
print type(newSingle[0])
print type(newSingle[0]['path'])
print system.tag.configure('[default]zachTest/dustCollection/',newSingle)
<type 'list'>
<type 'dict'>
<type 'com.inductiveautomation.ignition.common.tags.paths.BasicTagPath'>
[Good]
<type 'list'>
<type 'dict'>
<type 'com.inductiveautomation.ignition.common.tags.paths.BasicTagPath'>
13:18:27.475 [AWT-EventQueue-0] ERROR Scripting[util_tag] - Error converting PyTagDictionary to tag edit: 
java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.inductiveautomation.ignition.common.tags.model.TagPath. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
	at com.inductiveautomation.ignition.common.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeProperty(TagGson.java:661)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:638)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:624)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:967)
	at com.inductiveautomation.ignition.common.tags.TagUtilities.toTagConfiguration(TagUtilities.java:128)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.dictToTagEdits(AbstractTagUtilities.java:193)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.lambda$configure$0(AbstractTagUtilities.java:154)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
	at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.configure(AbstractTagUtilities.java:154)
	at jdk.internal.reflect.GeneratedMethodAccessor186.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:539)
	at org.python.core.PyObject.__call__(PyObject.java:497)
	at org.python.core.PyObject.__call__(PyObject.java:501)
	at org.python.pycode._pyx359.f$0(<event:actionPerformed>:16)
	at org.python.pycode._pyx359.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy55.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: com.inductiveautomation.ignition.common.tags.model.TagPath
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator.assertInstantiable(UnsafeAllocator.java:117)
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:49)
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
	... 83 common frames omitted
[Error_Configuration]

Try using this to deep convert the configuration object returned from getConfiguration into regular Python lists/dicts/strings:


from com.inductiveautomation.ignition.common import TypeUtilities
from com.inductiveautomation.ignition.common.tags.config import TagGson

sampleConfig = system.tag.getConfiguration(
	'[default]zachTest/dustCollection/airlockA',
	1
)

gson = TagGson.create()
sampleConfig = TypeUtilities.gsonToPy(TypeUtilities.pyToGson(sampleConfig, gson))

getConfiguration should probably return native data directly, but :man_shrugging:

Running exactly that throws a different error:

13:54:58.226 [AWT-EventQueue-0] ERROR com.inductiveautomation.ignition.client.util.gui.ErrorUtil - <HTML>Error executing script for event:&nbsp;<code><b>actionPerformed</b></code><BR>on component:&nbsp;<code><b>Button 2</b></code>.
com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last):
  File "<event:actionPerformed>", line 10, in <module>
TypeError: gsonToPy(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.gson.JsonElement

	at org.python.core.Py.TypeError(Py.java:265)
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:211)
	at org.python.core.PyReflectedFunction.throwBadArgError(PyReflectedFunction.java:314)
	at org.python.core.PyReflectedFunction.throwError(PyReflectedFunction.java:323)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:169)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:206)
	at org.python.core.PyObject.__call__(PyObject.java:480)
	at org.python.core.PyObject.__call__(PyObject.java:484)
	at org.python.pycode._pyx411.f$0(<event:actionPerformed>:10)
	at org.python.pycode._pyx411.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy55.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: org.python.core.PyException: Traceback (most recent call last):
  File "<event:actionPerformed>", line 10, in <module>
TypeError: gsonToPy(): 1st arg can't be coerced to com.inductiveautomation.ignition.common.gson.JsonElement

	... 53 common frames omitted

Slightly modified works for gsonToPy, but fails with the same error as before.
Script

import copy
from com.inductiveautomation.ignition.common import TypeUtilities
from com.inductiveautomation.ignition.common.tags.config import TagGson
from com.inductiveautomation.ignition.common.tags.paths import BasicTagPath

sampleConfig = system.tag.getConfiguration(
	'[default]zachTest/dustCollection/airlockA',
	1
)
gson = TagGson.create()
sampleConfig = TypeUtilities.gsonToPy(TypeUtilities.pyToGson(sampleConfig[0], gson))

print type(sampleConfig)
print type(sampleConfig)
print type(sampleConfig['path'])
print system.tag.configure('[default]zachTest/dustCollection/',[sampleConfig])

newSingle = copy.deepcopy(sampleConfig)
print type(newSingle)
print type(newSingle)
print type(newSingle['path'])
print system.tag.configure('[default]zachTest/dustCollection/',[newSingle])

Result. Note that now both system.tag.configure calls fail.

<type 'dict'>
<type 'dict'>
<type 'dict'>
13:58:09.393 [AWT-EventQueue-0] ERROR Scripting[util_tag] - Error converting PyTagDictionary to tag edit: 
java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.inductiveautomation.ignition.common.tags.model.TagPath. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
	at com.inductiveautomation.ignition.common.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeProperty(TagGson.java:661)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:638)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:624)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:967)
	at com.inductiveautomation.ignition.common.tags.TagUtilities.toTagConfiguration(TagUtilities.java:128)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.dictToTagEdits(AbstractTagUtilities.java:193)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.lambda$configure$0(AbstractTagUtilities.java:154)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
	at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.configure(AbstractTagUtilities.java:154)
	at jdk.internal.reflect.GeneratedMethodAccessor186.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:539)
	at org.python.core.PyObject.__call__(PyObject.java:497)
	at org.python.core.PyObject.__call__(PyObject.java:501)
	at org.python.pycode._pyx420.f$0(<event:actionPerformed>:22)
	at org.python.pycode._pyx420.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy55.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: com.inductiveautomation.ignition.common.tags.model.TagPath
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator.assertInstantiable(UnsafeAllocator.java:117)
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:49)
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
	... 83 common frames omitted
[Error_Configuration]
<type 'dict'>
<type 'dict'>
<type 'dict'>
13:58:09.409 [AWT-EventQueue-0] ERROR Scripting[util_tag] - Error converting PyTagDictionary to tag edit: 
java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.inductiveautomation.ignition.common.tags.model.TagPath. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
	at com.inductiveautomation.ignition.common.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeProperty(TagGson.java:661)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:638)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:624)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:967)
	at com.inductiveautomation.ignition.common.tags.TagUtilities.toTagConfiguration(TagUtilities.java:128)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.dictToTagEdits(AbstractTagUtilities.java:193)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.lambda$configure$0(AbstractTagUtilities.java:154)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
	at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.configure(AbstractTagUtilities.java:154)
	at jdk.internal.reflect.GeneratedMethodAccessor186.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:539)
	at org.python.core.PyObject.__call__(PyObject.java:497)
	at org.python.core.PyObject.__call__(PyObject.java:501)
	at org.python.pycode._pyx420.f$0(<event:actionPerformed>:22)
	at org.python.pycode._pyx420.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy55.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: com.inductiveautomation.ignition.common.tags.model.TagPath
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator.assertInstantiable(UnsafeAllocator.java:117)
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:49)
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
	... 83 common frames omitted
[Error_Configuration]

How about:

from com.inductiveautomation.ignition.common import TypeUtilities
from com.inductiveautomation.ignition.common.tags.config import TagGson

sampleConfig = system.tag.getConfiguration(
	'[default]zachTest/dustCollection/airlockA',
	1
)

gson = TagGson.create()
sampleConfig = system.util.jsonDecode(str(TypeUtilities.pyToGson(sampleConfig, gson)))

Closer (I think) but still not quite. Your code runs without error now, but the scrip below still results in the ‘Unable to invoke no-args constructor’ error.

Script:

from com.inductiveautomation.ignition.common import TypeUtilities
from com.inductiveautomation.ignition.common.tags.config import TagGson

sampleConfig = system.tag.getConfiguration(
	'[default]zachTest/dustCollection/airlockA',
	1
)
print system.tag.configure('[default]zachTest/dustCollection/',sampleConfig)

gson = TagGson.create()
sampleConfig = system.util.jsonDecode(str(TypeUtilities.pyToGson(sampleConfig, gson)))

print type(sampleConfig)
print type(sampleConfig[0])
print type(sampleConfig[0]['path'])
print sampleConfig[0]['path']
print system.tag.configure('[default]zachTest/dustCollection/',sampleConfig)

Console Output:

[Good]
<type 'list'>
<type 'dict'>
<type 'dict'>
{u'source': 'default', u'pathParts': ['zachTest', 'dustCollection', 'airlockA']}
15:37:46.201 [AWT-EventQueue-0] ERROR Scripting[util_tag] - Error converting PyTagDictionary to tag edit: 
java.lang.RuntimeException: Unable to invoke no-args constructor for interface com.inductiveautomation.ignition.common.tags.model.TagPath. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
	at com.inductiveautomation.ignition.common.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeProperty(TagGson.java:661)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:638)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserializeJsonObject(TagGson.java:624)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:566)
	at com.inductiveautomation.ignition.common.tags.config.TagGson$PropertySetTypeAdapter.deserialize(TagGson.java:515)
	at com.inductiveautomation.ignition.common.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:927)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:994)
	at com.inductiveautomation.ignition.common.gson.Gson.fromJson(Gson.java:967)
	at com.inductiveautomation.ignition.common.tags.TagUtilities.toTagConfiguration(TagUtilities.java:128)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.dictToTagEdits(AbstractTagUtilities.java:193)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.lambda$configure$0(AbstractTagUtilities.java:154)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source)
	at java.base/java.util.Iterator.forEachRemaining(Unknown Source)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	at com.inductiveautomation.ignition.common.script.builtin.AbstractTagUtilities.configure(AbstractTagUtilities.java:154)
	at jdk.internal.reflect.GeneratedMethodAccessor186.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:539)
	at org.python.core.PyObject.__call__(PyObject.java:497)
	at org.python.core.PyObject.__call__(PyObject.java:501)
	at org.python.pycode._pyx471.f$0(<event:actionPerformed>:17)
	at org.python.pycode._pyx471.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:799)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy55.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: Interface can't be instantiated! Interface name: com.inductiveautomation.ignition.common.tags.model.TagPath
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator.assertInstantiable(UnsafeAllocator.java:117)
	at com.inductiveautomation.ignition.common.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:49)
	at com.inductiveautomation.ignition.common.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
	... 83 common frames omitted
[Error_Configuration]

Sigh.
{u'source': 'default', u'pathParts': ['zachTest', 'dustCollection', 'airlockA']}
That’s a “more accurate” JSON representation of the tag path, but it’s not what you need to pass back through; when you’re writing back a configuration we expect the tag path to just be a regular string.

I think you might be better off handcranking this along (right click the UDT instance, copy the JSON, paste that string into your code and JSON parse it). I’m not well versed enough in the tag system code to tell you if there’s a more elegant way to get the info you’re after easier.

1 Like

I never thought of copying the JSON out of the tag browser, but that’s certainly a workable solution for this case. I kind of got tunnel vision on system.tag.configure. Thanks for the help.

1 Like