Skip to main content
Cadet | Tier 2
January 8, 2023
Solved

Bot Error calling Python function

  • January 8, 2023
  • 4 replies
  • 1870 views

New to AA so forgive me, spent too many hours trying to troubleshoot this, have seen posts from google search that also had it but no definitive solution and most of those old questions seem to have been purged from AA (sure wish they had not been removed or it could help!).

Meticulously went thru this tutorial:

https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/advanced-bots/cloud-build-bot-python.html

However, get “bot error” returned from the python function on line 4.

Have also tried the simplest possible function returning just a string - same “bot error”.  How do you properly troubleshoot and resolve this thing?  Have looked at logs in C:\ProgramData\AutomationAnywhere\BotRunner\Logs and not helpful.  Have checked my laptop’s env variable and it has the right python path, py from cmd works fine, etc, etc.  ???

    Best answer by Raul Jaimes

    @kerrykane ,

    Verify the enviroment variable in a cmd 

     

    C:\>echo %PATH%

    You should be  notice the binaries path fom python.

    C:\Users\username\AppData\Local\Programs\Python\Python310

    https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/commands/cloud-python-command.html

     

     

    Regards

    4 replies

    Raul Jaimes
    Navigator | Tier 3
    January 8, 2023

    @kerrykane ,

    Verify the enviroment variable in a cmd 

     

    C:\>echo %PATH%

    You should be  notice the binaries path fom python.

    C:\Users\username\AppData\Local\Programs\Python\Python310

    https://docs.automationanywhere.com/bundle/enterprise-v2019/page/enterprise-cloud/topics/aae-client/bot-creator/commands/cloud-python-command.html

     

     

    Regards

    kerrykaneAuthor
    Cadet | Tier 2
    January 8, 2023

    Thanks Raul, but I did check path already, it contains C:\Program Files\Python310\ and py works from command line.  I had checked that article last night, the NOTE in there about where logs are stored is interesting, but the logs here: C:\ProgramData\AutomationAnywhere\BotRunner\Logs seem to be updated each run, whereas the logs do not update each run here (WTH?):  C:\ProgramData\AutomationAnywhere\BotRunner\Logs\2023-Jan

    I am finding AA error handling remarkably unhelpful.

    Update:  There was a subtle but critical difference I had from the tutorial, line 2 which assigns the response from the Web Service to the destination string variable was set to $dResponseBody$ instead of the correct: $dResponse{Body}$.

    The only ‘helpful’ log entries were in 

    C:\ProgramData\AutomationAnywhere\BotRunner\Logs\Bot_Launcher_KKane.log and contained lines:
    containing lines:

    2023-Jan-08 Sun 11:53:58.661 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) - Traceback (most recent call last):
    2023-Jan-08 Sun 11:53:58.661 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\wrapper.py", line 86, in main
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     result = method_to_call(*args)
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-8] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) - 2023-01-08 11:53:58,660 - root - ERROR - Error Running bot function: Traceback (most recent call last):   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\wrapper.py", line 86, in main     result = method_to_call(*args)   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\bot.py", line 5, in get_node_count     response_dict=json.loads(response)   File "C:\Program Files\Python310\lib\json\__init__.py", line 346, in loads     return _default_decoder.decode(s)   File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode     obj, end = self.raw_decode(s, idx=_w(s, 0).end())   File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode     raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\bot.py", line 5, in get_node_count
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     response_dict=json.loads(response)
    2023-Jan-08 Sun 11:53:58.663 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Program Files\Python310\lib\json\__init__.py", line 346, in loads
    2023-Jan-08 Sun 11:53:58.663 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     return _default_decoder.decode(s)
    2023-Jan-08 Sun 11:53:58.663 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     raise JSONDecodeError("Expecting value", s, err.value) from None
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) - json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    2023-Jan-08 Sun 11:53:58.694 INFO  [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botrunner.bot.Bot_BKanePythonBot {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - handleThrowable(Bot_BKanePythonBot.java:552) - exception handled by parent:false
    2023-Jan-08 Sun 11:53:58.694 INFO  [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botrunner.bot.Bot_BKanePythonBot {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - handleThrowable(Bot_BKanePythonBot.java:555) - handleThrowable: running node_index_id: 6, error_node_index
    2023-Jan-08 Sun 11:53:58.698 INFO  [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botengine.service.impl.DispatcherImpl {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - getSize(DispatcherImpl.java:581) - Bot output size 0
    2023-Jan-08 Sun 11:53:58.700 ERROR [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botrunner.bot.Bot_BKanePythonBot {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - handleThrowable(Bot_BKanePythonBot.java:559) - bot status 'FAILED' updated com.automationanywhere.botcommand.exception.BotCommandException: The input entered in 'sourceString' is incorrect.
        at com.automationanywhere.botcommand.string.commands.ToNumberCommand.execute(ToNumberCommand.java:55) ~[bot-command-string-5.5.2-20221006-094641.jar:?]
     

    Lesson:  You must carefully check types and values of input params, use the AA debugger to watch variable values at each step, and expect to sift thru very busy log files for clues if you get the ‘bot error’ message.

    @Raul Jaimes I appreciate your response and help, I’m sure that PATH variable is also something you must check!

    Raul Jaimes
    Navigator | Tier 3
    January 9, 2023

    Thanks Raul, but I did check path already, it contains C:\Program Files\Python310\ and py works from command line.  I had checked that article last night, the NOTE in there about where logs are stored is interesting, but the logs here: C:\ProgramData\AutomationAnywhere\BotRunner\Logs seem to be updated each run, whereas the logs do not update each run here (WTH?):  C:\ProgramData\AutomationAnywhere\BotRunner\Logs\2023-Jan

    I am finding AA error handling remarkably unhelpful.

    Update:  There was a subtle but critical difference I had from the tutorial, line 2 which assigns the response from the Web Service to the destination string variable was set to $dResponseBody$ instead of the correct: $dResponse{Body}$.

    The only ‘helpful’ log entries were in 

    C:\ProgramData\AutomationAnywhere\BotRunner\Logs\Bot_Launcher_KKane.log and contained lines:
    containing lines:

    2023-Jan-08 Sun 11:53:58.661 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) - Traceback (most recent call last):
    2023-Jan-08 Sun 11:53:58.661 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\wrapper.py", line 86, in main
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     result = method_to_call(*args)
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-8] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) - 2023-01-08 11:53:58,660 - root - ERROR - Error Running bot function: Traceback (most recent call last):   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\wrapper.py", line 86, in main     result = method_to_call(*args)   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\bot.py", line 5, in get_node_count     response_dict=json.loads(response)   File "C:\Program Files\Python310\lib\json\__init__.py", line 346, in loads     return _default_decoder.decode(s)   File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode     obj, end = self.raw_decode(s, idx=_w(s, 0).end())   File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode     raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Users\kkane\AppData\Local\AA\resources\f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616\9f09e0dc-74c7-403b-98c8-1a8e5affac8d\bot.py", line 5, in get_node_count
    2023-Jan-08 Sun 11:53:58.662 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     response_dict=json.loads(response)
    2023-Jan-08 Sun 11:53:58.663 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Program Files\Python310\lib\json\__init__.py", line 346, in loads
    2023-Jan-08 Sun 11:53:58.663 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     return _default_decoder.decode(s)
    2023-Jan-08 Sun 11:53:58.663 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Program Files\Python310\lib\json\decoder.py", line 337, in decode
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -   File "C:\Program Files\Python310\lib\json\decoder.py", line 355, in raw_decode
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) -     raise JSONDecodeError("Expecting value", s, err.value) from None
    2023-Jan-08 Sun 11:53:58.664 INFO  [Thread-9] - ExternalScript {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - log_aroundBody0(LogUtil.java:32) - json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    2023-Jan-08 Sun 11:53:58.694 INFO  [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botrunner.bot.Bot_BKanePythonBot {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - handleThrowable(Bot_BKanePythonBot.java:552) - exception handled by parent:false
    2023-Jan-08 Sun 11:53:58.694 INFO  [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botrunner.bot.Bot_BKanePythonBot {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - handleThrowable(Bot_BKanePythonBot.java:555) - handleThrowable: running node_index_id: 6, error_node_index
    2023-Jan-08 Sun 11:53:58.698 INFO  [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botengine.service.impl.DispatcherImpl {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - getSize(DispatcherImpl.java:581) - Bot output size 0
    2023-Jan-08 Sun 11:53:58.700 ERROR [BotRunner-f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616] - com.automationanywhere.botrunner.bot.Bot_BKanePythonBot {deploymentId=f55a0c68-76fd-44e3-bf3a-8fd5d4dab285_8974d35a44b05616, traceId=8974d35a44b05616} - handleThrowable(Bot_BKanePythonBot.java:559) - bot status 'FAILED' updated com.automationanywhere.botcommand.exception.BotCommandException: The input entered in 'sourceString' is incorrect.
        at com.automationanywhere.botcommand.string.commands.ToNumberCommand.execute(ToNumberCommand.java:55) ~[bot-command-string-5.5.2-20221006-094641.jar:?]
     

    Lesson:  You must carefully check types and values of input params, use the AA debugger to watch variable values at each step, and expect to sift thru very busy log files for clues if you get the ‘bot error’ message.

    @Raul Jaimes I appreciate your response and help, I’m sure that PATH variable is also something you must check!

    Thank you very much your feedback. It enriches the Pathfinder community!

    You can set some messages box before you call variables in order to identify if any variable has an expected value or not along with debugger.

    Regards

    Automation Anywhere Team
    February 13, 2023

    Hi kerrykane,

     

    If you are still facing an issue, can reach out to me.