Getting json parse error since Dec 4 right after system maintenance
I am getting a JSON parsing error in Run Javascript step since Zapier did system maintenance on Dec 4 around 5:44pm.
Here are the details:
The JSON I am trying to parse is coming from Slack. A sample JSON is this: {"filename": "LOW 1050311887 3/1/2025", "type": "check"}
Error I am getting is: Your code had an error. See details below: Error: SyntaxError: Unexpected token u in JSON at position 0 at <code> (line 1, column 23)
code
let PARSED = JSON.parse(inputData.RAW); output = {PARSED}]
input
RAW
{{242106831__raw_text}}
Instead of parsing the correct raw, it’s showing the above.
Page 1 / 1
Hey @Ban Salad ,
I think i found the solution. Can you enter RAW in small caps? and in your javascript code use raw instead of RAW
Below is the screenshot of the code -
Hi @Ban Salad
If you still need help, post screenshots showing how your Zap Code step is configured in EDIT mode so we can see the inputs and code.
Hey @Troy Tessalone ,
Making raw in lower case did not help. Please see the screenshots below:
Interestingly when I run in Edit mode as Test, it gives the correct output. But when the same message comes through slack, it gives the above error in red.
@Ban Salad
If you are using JavaScript in the Code step, then to declare variables use:
You can access data from previous steps via the inputData dictionary variable in your code step. The amount of data that may feed into your script may be large or dynamic. To address this, you must define an inputData mapping by providing a key and value in Zapier's GUI.
You can't map fields from previous Zap steps to the Code field. You must use the Input Data dictionary.
You can create a key/value pair in the Input Data field for each mapped field you want to use in your code.
In Javascript, you can access the inputData dictionary variable values by using the inputData.keyName or inputDatat"keyName"] notation. Key names are case-sensitive and must be an exact match when referenced.
In the example below, the key name is "defineName" and the value is supplied by the Name field that's mapped from a previous step. In this example, the value supplied by the mapped Name field is "Jane".
I tried with using `inputData` and still get the same error. I tried using `input_data` because of trying switching to Python, but that did not work.
See the screenshot below with inputData.
One thing to note is that something happened on Dec. 4 after maintenance at 5:44pm EST. Zap run successfully around 4:47pm that day, but then started failing after 6pm. I always had inputData.RAW with no change to the code.
@Ban Salad
The DATA OUT from the Zap Run indicates the mapped variables has no value or is an invalid variable, so that i likely contributing to the error.
Try adding a Filter step as Zap step 2 to make sure the Input Data variable for “raw” in the Code step exists before the Zap proceeds.
For us to have more info, post these screenshots:
The field in the SETUP tab for the Code step to verify if you are using JavaScript or Python
The “Raw Text” variable value output as shown in the TEST tab from Zap step 1 to make sure it is valid JSON to parse.
I am thinking if there’s some sort of race condition because all the tests are all good when editing draft. Timing has to be involved somehow.
Along with filter step, is there a sleep step that waits for say 5-10 seconds before proceeding? Or may be loop that checks if raw is valid json for a finite time?
@Ban Salad
To help you troubleshoot, check your Zap Runs history details to see the DATA IN/OUT for each step: https://zapier.com/app/history/
Thanks @Troy Tessalone. I think I am getting somewhere with looking at the history. Looks like some changes in the schema by Zapier did not make my code work.
See the snapshot of the data from slack just before maintenance.
And here’s the snapshot of the data just after maintenance.
Looks like the Raw text field somehow renamed and it’s not capturing the correct value in the next Javascript step.
@Ban Salad
For the “After”, Zapier is parsing the JSON for you.
Thanks. Looking into it. But this change from Zapier seems incomplete and broken. Selecting the InputData field shows Raw Text as a json but can’t be used.
@Ban Salad
If you use the custom variables, then you won’t need the Code step to parse the JSON.