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

:undef still shows up in types and providers

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • PUP 5.5.6
    • PUP 6.0.0
    • Types and Providers
    • None
    • Hide

      Ideally, providers should receive nil rather than :undef, consistent with the behavior of functions and templates.

      If that is not possible, Puppet::Util should provide a convenience method to recursively travel a nested hash/array structure transforming :undef into nil. This method (and the problem it solves) should be documented.

      Show
      Ideally, providers should receive nil rather than :undef , consistent with the behavior of functions and templates. If that is not possible, Puppet::Util should provide a convenience method to recursively travel a nested hash/array structure transforming :undef into nil . This method (and the problem it solves) should be documented.
    • Platform Core
    • Needs Assessment
    • Deprecation
    • Hide
      In versions before Puppet 6.0.0 values from manifests assigned to resource attributes that contained undef values nested in arrays and hashes would use the Ruby symbol :undef to represent those values. When using puppet apply types and providers would see those as :undef or as the string "undef" depending on the implementation of the type. When using a puppet master, the same values were correctly handled. In Puppet 6.0.0 Ruby {{nil}} is used consistently for this. (Top level undef values are still encoded as empty string for backwards compatibility).
      Show
      In versions before Puppet 6.0.0 values from manifests assigned to resource attributes that contained undef values nested in arrays and hashes would use the Ruby symbol :undef to represent those values. When using puppet apply types and providers would see those as :undef or as the string "undef" depending on the implementation of the type. When using a puppet master, the same values were correctly handled. In Puppet 6.0.0 Ruby {{nil}} is used consistently for this. (Top level undef values are still encoded as empty string for backwards compatibility).
    • Needs Assessment

    Description

      Puppet Version: 5.5.6
      Puppet Server Version: N/A
      OS Name/Version: Centos 7, same on Windows 10

      Per the discussion in PUP-1467, all Ruby code in Types and Providers is supposed to receive undef values as nil. However, in at least some circumstances, I am receiving the Symbol :undef instead.

      For example, given the following resource declaration:

       

      foo { 'bar':
        baz => {
          quux => undef,
        },
      }
      

       

      Desired Behavior:

      Inside the provider, resource[:baz] evaluates to {'quux' => nil}

      Actual Behavior:

      Inside the provider, resource[:baz] evaluates to {'quux' => :undef}

      Additional Context

      Besides behaving contrary to the discussions in PUP-1467 (which is the closest I could find to documentation on :undef vs nil, this is also problematic when the provider is constructing JSON, perhaps to communicate with an API; the desired JSON string would be {"quux": null}, but instead you end up with {"quux": "undef"}.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              adam.gardner Adam Gardner
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support