Project

General

Profile

Actions

Bug #18287

closed

Only first element of root array is collected

Added by François ARMAND over 3 years ago. Updated over 2 years ago.

Status:
Released
Priority:
N/A
Target version:
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.


Subtasks 1 (0 open1 closed)

Bug #18310: Broken datasources testReleasedFrançois ARMANDActions

Related issues 1 (0 open1 closed)

Related to Datasources - Bug #18288: Add tests regarding arraysReleasedVincent MEMBRÉActions
Actions #1

Updated by François ARMAND over 3 years ago

  • Related to Bug #18288: Add tests regarding arrays added
Actions #2

Updated by François ARMAND over 3 years ago

  • Status changed from New to In progress
Actions #3

Updated by François ARMAND over 3 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
Actions #4

Updated by François ARMAND over 3 years ago

  • Status changed from Pending technical review to Pending release
Actions #5

Updated by Vincent MEMBRÉ over 2 years ago

  • Status changed from Pending release to Released
Actions

Also available in: Atom PDF