Code tool fails when null property exists in object #4870

Closed
opened 2026-02-21 18:08:23 -05:00 by yindo · 3 comments
Owner

Originally created by @dnyg on GitHub (Aug 2, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, 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).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.6.15

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Create a Code block
  2. Set output variable to be object
  3. Add following code:
function main() {
    return {
        result: {
            a: null
        }
    }
}

✔️ Expected Behavior

That the code block returns the result object with the a property set to null

Actual Behavior

I get the error:

Output .result.a is not a valid type.

Originally created by @dnyg on GitHub (Aug 2, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, 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] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.6.15 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Create a `Code` block 2. Set output variable to be object 3. Add following code: ``` function main() { return { result: { a: null } } } ``` ### ✔️ Expected Behavior That the code block returns the result object with the a property set to null ### ❌ Actual Behavior I get the error: >Output .result.a is not a valid type.
yindo added the 🐞 bug label 2026-02-21 18:08:23 -05:00
yindo closed this issue 2026-02-21 18:08:23 -05:00
Author
Owner

@rhardih commented on GitHub (Aug 2, 2024):

Same behaviour for Python as well, setting the output to be an Object as well.

def main():
    return {
        "result": {
            "prop": None
        }
    }
@rhardih commented on GitHub (Aug 2, 2024): Same behaviour for Python as well, setting the output to be an Object as well. ```python def main(): return { "result": { "prop": None } } ```
Author
Owner

@dosubot[bot] commented on GitHub (Aug 2, 2024):

The error occurs because Dify version 0.6.15 does not accept null as a valid type for the property a in the result object. To resolve this issue, you need to ensure that the property a is set to a valid type that Dify accepts, such as an empty string or another default value.

Here is the corrected code:

function main() {
    return {
        result: {
            a: ""
        }
    }
}

This should prevent the error and return the result object with the a property set to an empty string [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Aug 2, 2024): <!-- Answer --> The error occurs because Dify version 0.6.15 does not accept `null` as a valid type for the property `a` in the `result` object. To resolve this issue, you need to ensure that the property `a` is set to a valid type that Dify accepts, such as an empty string or another default value. Here is the corrected code: ```javascript function main() { return { result: { a: "" } } } ``` This should prevent the error and return the `result` object with the `a` property set to an empty string <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/package.json)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@greycodee commented on GitHub (Aug 5, 2024):

I'm trying to fix that.

@greycodee commented on GitHub (Aug 5, 2024): I'm trying to fix that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4870