Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-8320

True/truthy inconsistencies between function filter() and functions all() and any()

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 6.0.0
    • Component/s: DOCS
    • Labels:
      None
    • Template:
    • Team:
      Platform Core
    • Sub-team:
    • Story Points:
      1
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      The {{filter}} function did not accept truthy value returned from the block as indication of values to include in the result. Only exactly boolean {{true}} was earlier accepted.
    • QA Risk Assessment:
      Needs Assessment

      Description

      There are inconsistencies in how the result of a predicate block sent to the Puppet functions all, any, and filter is acted upon.

      The filter function checks if the value returned from the block is exactly equal to the literal true whereas the all and any functions checks if it is truthy (i.e. not literal false or undef).

      Although the inconsistency is also present in the documentation, it would be desirable if all iterative functions that uses a predicate block use the same behavior.

      Proposed change:
      Modify the filter function so that it also acts on truthy returns since this is also consistent with how if and unless works and also modify the documentation to state this.

      This is a breaking change.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                thomas.hallgren Thomas Hallgren
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: