JSON Encode error: object has no attribute jsonEncode

I have implemented a doPost operation using the webdev. At the end of the code it is used the function system.util.jsonEncode(dic) where a dictionary is given as the argument of the function through a variable. The type of this variable is a dictionary, but once in a while when running a post operation against this web server it throws the following error in the ignition log:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 92, in doPost AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'jsonEncode'

The line where the error was raised is:
functions.logger.info(system.util.jsonEncode(info))

The function is correctly called and the variable is a dictionary so does not make sense that this error were raised. As I said this does not happen every time this code is executed, just once in a while, but whithout any specific pattern, or at least none that has been noticed. Once the error appear, the only way to prevent the error to be raise is by executing it in tow steps as follows:

infoJsonString = system.util.jsonEncode(info)
functions.logger.info(infoJsonString)

So, this behaviour of ignition does not make any sense for me. Don’t know if there is any bug that can cause it or if I am doing something wrong. So I was wondering how to fix it.

Thanks!

Mario

  1. What version of Ignition is this?
  2. Are you accidentally rebinding or modifying system along some code path? You can both shadow and mutate the system package objects that are automatically introduced into scope.
  3. Are you explicitly importing system or any other project library in your code? (don't do this)
  4. If you move your entire script to the project library and make you webdev endpoint a one-line script that simply calls it, providing all the webdev module's parameters, does the issue still occur?