system.util.jsonEncode(system.tag.getConfiguration()) exceeds maximum recursion depth / why can't we export MQTT Tag Configuration?

I’m trying to use this to export tag configuration to json so I can synchronize tag configuration with another server: system.util.jsonEncode(system.tag.getConfiguration('[MQTT Engine]Edge Nodes/Site1', True)), but then I get this:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded (Java StackOverflowError)

It does this for all tags (not just MQTT). Is this expected? It also does it whether I use the path of a single tag or a large folder.

I was able to work around this in perspective by sending the output of system.tag.getConfiguration to a property using a binding, then encoding the value of the property, but even then I get Error_Configuration("java.lang.IllegalStateException: Not a JSON Object when I try to configure tags with that json using system.tag.configure.

I know I can do this with the Tag Export tool for regular tags, but I can’t export MQTT tags with that so I’m resorting to this.

1 Like

This is unexpected but a known issue that we've already got logged.

The workaround on the ticket is to cast each of the dictionaries returned in the getConfiguration result to string before passing to system.util.jsonEncode.

result = system.tag.getConfiguration(PathToTag)
print system.util.jsonEncode(str(result[0]))

What are you hoping to achieve in the end? You aren't going to be able to create or modify MQTT tags by importing whatever you manage to export. They are managed by the MQTT modules.

Thanks Kevin, I’ll try this out. The scenario is that there is a development MQTT Engine environment and a production MQTT Engine environment subscribed to the same broker. A fair amount of configuration was done on the MQTT tags in the development environment (alarms, historization,etc.) and we don’t want to have to manually configure the exact same thing on the production environment. I had the thought that we could use system.tag.getConfiguration to export the configuration to JSON, and then set the configuration of the tags on production to the same as dev by importing the JSON and using system.tag.configure().

I tested using system.tag.configure to modify one tag and tags underneath a folder within the MQTT tree and that worked, then got stuck at the JSON conversion step. I’m totally open to suggestions/recommendations if there is a better way.

Hmm, you may very well be able to modify them like that. My working knowledge of the type of tag provider being used by the MQTT modules is a little out of date. If it works then carry on.

Doing this workaround just gives me a string that looks like this {u\'dataType\': Int8, u\'sampleMode\': ...} and doesn’t appear to be compatible with system.util.jsonDecode or to use with system.tag.configure.

1 Like

Hmm… yeah, I don’t think the workaround on the ticket does what the person who wrote it thinks.

I linked this post to the ticket, hopefully that bumps the priority a little.

2 Likes

v8.1.30
I'm seeing this issue as well, with a fairly simple dictionary (it contains a list and dictionary field).
Any updates?

v8.1.35
still same issue

any updates?