"Invalid value selector" occurred when pass textarea input params to code execute node
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.6.11
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I create a workflow,and make several input params, some of them are textarea:
I find when the textarea params contains line break, the code execute node get error:
after i remove systemMessage param,everything goes ok
✔️ Expected Behavior
code execute node run successfully
❌ Actual Behavior
code execute node occurred error:Invalid value selector
Hello @all4you! I'm here to assist you with any bugs, questions, or contributions you may have. Let's work together to resolve the issue you're experiencing.
The "Invalid value selector" error in the convert_body node is likely caused by a mismatch between the expected and actual structure of the input parameters. Specifically, this error can occur if the query_variable_selector does not match the expected format or if the variable referenced in the selector is not found in the provided input parameters.
Here are some potential causes and solutions:
-
Variable Selector Mismatch: Ensure that the
variable_selectorin your node configuration correctly matches the input parameters. For example, if yoursystemMessageparameter is expected to be used in theconvert_bodynode, make sure it is correctly referenced. -
Multiline Text Handling: The
convert_bodynode should handle multiline text inputs properly. Ensure that the input parameters are correctly formatted and that any special characters, such as line breaks, are properly encoded. -
Validation and Parsing: The
convert_bodynode uses various methods to validate and parse input parameters. Ensure that the input parameters conform to the expected types and structures. For example, the_check_stringmethod ensures that the value is a string and replaces any null characters (\x00).
Here is a relevant snippet from the test case that demonstrates how the variable_selector is used:
def test_execute_if_else_result_true():
node = IfElseNode(
tenant_id='1',
app_id='1',
workflow_id='1',
user_id='1',
user_from=UserFrom.ACCOUNT,
invoke_from=InvokeFrom.DEBUGGER,
config={
'id': 'if-else',
'data': {
'title': '123',
'type': 'if-else',
'logical_operator': 'and',
'conditions': [
{
'comparison_operator': 'contains',
'variable_selector': ['start', 'array_contains'],
'value': 'ab'
},
# other conditions...
]
}
}
)
# construct variable pool
pool = VariablePool(system_variables={
SystemVariable.FILES: [],
SystemVariable.USER_ID: 'aaa'
}, user_inputs={})
pool.append_variable(node_id='start', variable_key_list=['array_contains'], value=['ab', 'def'])
# other variable appends...
# Mock db.session.close()
db.session.close = MagicMock()
# execute node
result = node._run(pool)
assert result.status == WorkflowNodeExecutionStatus.SUCCEEDED
assert result.outputs['result'] is True
In this test, if the variable_selector ['start', 'array_contains'] does not match any variable in the input parameters, it could lead to an "Invalid value selector" error [1].
Additionally, the _convert_to_knowledge_retrieval_node method in the WorkflowConverter class sets the query_variable_selector based on the app mode and retrieve configuration. If the retrieve_config.query_variable is not provided or does not match the expected format, it can also result in an "Invalid value selector" error [2].
Ensure that your input parameters and their selectors are correctly configured to avoid this error.
To continue talking to Dosu, mention @dosu.
I found a very wired thing, when I naming the textarea input params start with 'sysXX' like : systemMessage,sysMessage, it cause the bug, when I change the name to prompt , it is ok.
when I change it to systemPrompt:
the 'start' node is missing, and then the bug occurred
Test on v0.6.12-fix1
-
messagein Code execution node and end node work fine -
sys_messgaein Code execution node work fail -
sysmessgein Code execution node work fail -
systemMessagein Code execution node work fail -
messagein code execution work fine,systemMessagein end node, work fail