-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ParseJSONDataComponent prevent unnecessary array wrapping #4357
fix: ParseJSONDataComponent prevent unnecessary array wrapping #4357
Conversation
CodSpeed Performance ReportMerging #4357 will degrade performances by 21.05%Comparing Summary
Benchmarks breakdown
|
bf80f13
to
fe242d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there! Hope you're doing well, and thanks for the PR!
Would you mind also correcting the following lines in the tests?
diff --git a/src/backend/tests/integration/components/helpers/test_parse_json_data.py b/src/backend/tests/integration/components/helpers/test_parse_json_data.py
index d0aff47ca..7b5a1c3ff 100644
--- a/src/backend/tests/integration/components/helpers/test_parse_json_data.py
+++ b/src/backend/tests/integration/components/helpers/test_parse_json_data.py
@@ -37,7 +37,7 @@ async def test_from_message():
ParseJSONDataComponent,
inputs={
"input_value": ComponentInputHandle(clazz=ChatInput, inputs={}, output_name="message"),
- "query": ".[0].key",
+ "query": ".key",
},
run_input="{'key':'value1'}",
)
@@ -47,7 +47,7 @@ async def test_from_message():
ParseJSONDataComponent,
inputs={
"input_value": ComponentInputHandle(clazz=ChatInput, inputs={}, output_name="message"),
- "query": ".[0].key.[0].field2",
+ "query": ".key.[0].field2",
},
run_input='{"key":[{"field1": 1, "field2": 2}]}',
)
Head branch was pushed to by a user without write access
@italojohnny Updated. Thnx! |
Prevent wrapping non-array inputs in arrays to ensure correct JSON parsing and filtering.
159f705
to
4424571
Compare
…low-ai#4357) * fix(ParseJSONDataComponent): prevent unnecessary array wrapping Prevent wrapping non-array inputs in arrays to ensure correct JSON parsing and filtering. * [autofix.ci] apply automated fixes * updated failing test --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary: Prevent wrapping non-array inputs in arrays to ensure correct JSON parsing and filtering.
This PR addresses an issue where the ParseJSONDataComponent was always wrapping the input in an array, even if the input was not an array. This caused incorrect JSON parsing and filtering.
Changes
Modified the filter_data method to check if the input is a list before wrapping it.
If the input is not a list, it is processed as a single value.
If the input is a list, each item is processed separately.
Testing:
Run jq query -
.
output
output