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

Document Puppet::FileSystem.open / exclusive_open encoding usage, and make existing code explicitly use encodings

    XMLWordPrintable

Details

    • Hide
      • Verify exclusive open fails before applying the change.
      • Verify passes after change.
      • Double-check Forge for modules that make calls to filesystem methods and notify authors if they are using filesystem methods that will be not be backwards compatible with our changes.
      • Validate whether PUP-1583 is fixed by this.
      Show
      Verify exclusive open fails before applying the change. Verify passes after change. Double-check Forge for modules that make calls to filesystem methods and notify authors if they are using filesystem methods that will be not be backwards compatible with our changes. Validate whether PUP-1583 is fixed by this.
    • Agent
    • 3
    • AP 2016-10-19, AP 2016-11-02, AP 2016-11-16, AP 2016-11-30, AP 2016-12-14
    • Not Needed
    • No Action
    • N/A [mass update]: Various build, documentation, infra, or test-related issues

    Description

      The current FileSystem.open implementation is a bit peculiar at https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_system/file_impl.rb#L30-L32:

      def open(path, mode, options, &block)
        ::File.open(path, options, mode, &block)
      end
      

      The signature of the underlying Ruby method is open(filename [, mode [, perm]] [, opt], &block) - which means that we have shuffled and renamed some of Rubys parameters:

      • Rubys perm in our call is renamed as mode, and is moved from position 2 to position 1
      • Rubys mode in our call is renamed as options, and is moved from position 1 to position 2
      • We don't support the passing in of Rubys opt which is where one would set :encoding => 'utf-8'

      Fortunately there are only a few callsites which use FileSystem.open that are currently impacted:

      Note that both the calls to FileSystem.open and FileSystem.exclusive_open are impacted.

      At the time this PR goes up, another scan should occur to make sure that all callsites are corrected.

      Attachments

        Issue Links

          Activity

            People

              ethan Ethan Brown
              ethan Ethan Brown
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support