If a JSON value is true or false, python code function will run into NameError. #2400

Closed
opened 2026-02-21 17:45:17 -05:00 by yindo · 0 comments
Owner

Originally created by @Troublesis on GitHub (Apr 21, 2024).

Originally assigned to: @Yeuoly on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a quesion, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.6.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When you passed an Array[Object] variable into Python3 Code Block, if the JSON values has true or false as one of the JSON variable value, it will run into NameError.

image

image

You can see the below code. I did not change the python code, but if the value has " mark, It will successfully run.

Note

I am having this issue, because I am creating some workflows using Google Calendar API, the API value returns result which contains true and false (I didn't really intend to pass these values myself). Part of the API result example as below:

  "organizer": {
    "email": "test@gmail.com",
    "self": true
  }
image

✔️ Expected Behavior

It should successfully return the result as it is or at lease it should allow you to use try except to bypass the error, but even I tired to use try expect, i can not bypass this error.

Actual Behavior

It shows NameError at the Code Block.
Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 12, in <module> NameError: name 'false' is not defined error: exit status 255

Originally created by @Troublesis on GitHub (Apr 21, 2024). Originally assigned to: @Yeuoly on GitHub. ### Self Checks - [X] This is only for bug report, if you would like to ask a quesion, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version 0.6.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When you passed an `Array[Object]` variable into `Python3 Code Block`, if the `JSON` values has `true` or `false` as one of the JSON variable value, it will run into `NameError`. <img width="972" alt="image" src="https://github.com/langgenius/dify/assets/40723560/359844d8-82c9-43ab-933b-583d38b2478e"> <img width="450" alt="image" src="https://github.com/langgenius/dify/assets/40723560/840582be-b881-491c-90be-36b3535fe69c"><br> You can see the below code. I did not change the python code, but if the value has " mark, It will successfully run. > [!NOTE] > I am having this issue, because I am creating some workflows using Google Calendar API, the API value returns result which contains `true` and `false` (I didn't really intend to pass these values myself). Part of the API result example as below: ``` "organizer": { "email": "test@gmail.com", "self": true } ``` <img width="415" alt="image" src="https://github.com/langgenius/dify/assets/40723560/2f0f152c-e2fc-4c86-807e-ab90de58e666"> ### ✔️ Expected Behavior It should successfully return the result as it is or at lease it should allow you to use `try` `except` to bypass the error, but even I tired to use `try` `expect`, i can not bypass this error. ### ❌ Actual Behavior It shows NameError at the `Code Block`. `Traceback (most recent call last): File "<string>", line 40, in <module> File "<string>", line 12, in <module> NameError: name 'false' is not defined error: exit status 255`
yindo added the 🐞 bug label 2026-02-21 17:45:17 -05:00
yindo closed this issue 2026-02-21 17:45:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#2400