Skip to main content
Question

Can't run python script

  • November 7, 2025
  • 1 reply
  • 18 views

Forum|alt.badge.img+2

I am trying to run a python script to parse some data and run some API calls. As soon as the first line of the function is reached, the bot fails, but the script does keep running in the background and completes. 

I’ve put a return statement in the first line and it does return, but as soon as it hits the json.loads, it fails.

def myFunction(jsonString):   

    jsonData = json.loads(jsonString)

    .

    .

    .

 

Any help would be appreciated. 

1 reply

Padmakumar
Premier Pathfinder | Tier 7
Forum|alt.badge.img+15
  • Premier Pathfinder | Tier 7
  • 1170 replies
  • November 10, 2025

Hi ​@jasont,

 

From the given details, I can think of the below root causes for this issue.

 

1. You’re not actually receiving valid JSON

  • In AA, when you pass a Dictionary/Record or an object as a string, it often becomes a Python-like string with single quotes and possibly type-like prints (e.g., {'key': 'val'}), which is not valid JSON (JSON requires double quotes).
  • json.loads() will raise a JSONDecodeError on this.

2. You may already be receiving a Python dict

  • If you use AA’s Python package → Run function and pass a “Dictionary” as a parameter, AA may marshal it, and your function receives a Python dict, not a JSON string.
  • In that case, json.loads() will raise TypeError: the JSON object must be str, bytes, or bytearray, not dict.

3. Hidden characters / encoding issues

  • Sometimes strings include a BOM (\ufeff), non‑breaking spaces, or unescaped backslashes, which make json.loads() fail.

4. AA marks the action as Fail on any uncaught exception

  • Even if your script continues (for example, you started a background thread or the exception was caught elsewhere), the AA action that executed json.loads() will be flagged as failed.

 

 

If you can share a few more details, I can be more helpful on this.

  • How are you invoking the Python (AA Run function or external run)?
  • What’s the exact value/type of jsonString at runtime (a short sample and whether it uses single/double quotes)?
  • AA360 version and the “Python” package version you’re using.