Actions
Bug #18287
closedOnly first element of root array is collected
Pull Request:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
To do
Fix check:
To do
Regression:
Description
If you have a datasource whose API+JSONPath returns:
[ 1, 2 ]
Then only 1
is added in node property.
On the other hand, today we return - as expected:
- api returns { "a": "b" } - JSONPath '$' (select all) - node property is: { "a": "b" }
But as JSONPath always returns an array, we should get
[ {"a":"b"} ]
in node property, which would be extremelly surprising. Moreover, we special case
[]
since it means that the property was not found, and in data sources logic it means that it needs to be removed. Finally, we don't want to break existing code.
So we evolve the rule like that:
Considering JSONPath always returns an array, if JSONPath output is:
- an empty array (and only the root array, this not recursice), we remove the property,
- if the array contains exactly one element, we remove the outmost array and only that one. Note that is means that [:1]
kind of filter will fall in that case.
- if the array has more than one element, we return the array.
Updated by François ARMAND about 4 years ago
- Related to Bug #18288: Add tests regarding arrays added
Updated by François ARMAND about 4 years ago
- Status changed from New to In progress
Updated by François ARMAND about 4 years ago
- Status changed from In progress to Pending technical review
- Assignee changed from François ARMAND to Vincent MEMBRÉ
- Pull Request set to https://github.com/Normation/rudder-plugins/pull/338
Updated by François ARMAND about 4 years ago
- Status changed from Pending technical review to Pending release
Applied in changeset rudder:rudder-plugins|9cbdfb23ca63dc26cad163030e60803bf0d2c2ba.
Updated by Vincent MEMBRÉ about 3 years ago
- Status changed from Pending release to Released
Actions