puppetlabs / puppetlabs-apt

Puppet module to help manage Apt
https://forge.puppetlabs.com/puppetlabs/apt
Apache License 2.0
215 stars 462 forks source link

Variables ($release) that are defined as undef are breaking with '' validation #1089

Closed mcka1n closed 1 year ago

mcka1n commented 1 year ago

Describe the Bug

Martin Alfke (@tuxmea) found a bug and reached out to us at the Conf Management Conference.

The issue is that this line breaks:

https://github.com/puppetlabs/puppetlabs-apt/blob/main/templates/pin.pref.epp#L6

https://github.com/puppetlabs/puppetlabs-apt/blob/main/manifests/pin.pp#L51

Because the variable changed to undef and the validation.

Expected Behavior

The validation doesn't break

Steps to Reproduce

Steps to reproduce the behavior:

  1. Use the apt module, and try to call any of the Strings defined in the module

https://github.com/puppetlabs/puppetlabs-apt/blob/main/manifests/pin.pp#L51

image
  1. Click on '....'

Environment

Additional Context

Martin might add more context about this bug

@tuxmea

tuxmea commented 1 year ago

Reproducing the bug:

  include apt
  apt::pin { 'test2':
    release => 'buster',
  }

Produces:

cat /etc/apt/preferences.d/test2.pref
# This file is managed by Puppet. DO NOT EDIT.
Explanation: : test2
Package: *
Pin: release a=buster, n=, v=, c=, o=, l=
Pin-Priority: 0

With my patch the result will be the following:

cat /etc/apt/preferences.d/test2.pref
# This file is managed by Puppet. DO NOT EDIT.
Explanation: : test2
Package: *
Pin: release a=buster
Pin-Priority: 0