Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql::Db parameter 'tls_options' expects a value of type Undef or Array, got String #1539

Open
alexbugl opened this issue Mar 2, 2023 · 3 comments · Fixed by janit42/puppetlabs-mysql#1 · May be fixed by #1540
Open

Mysql::Db parameter 'tls_options' expects a value of type Undef or Array, got String #1539

alexbugl opened this issue Mar 2, 2023 · 3 comments · Fixed by janit42/puppetlabs-mysql#1 · May be fixed by #1540

Comments

@alexbugl
Copy link

alexbugl commented Mar 2, 2023

Describe the Bug

After update of v13.1.0 to v13.2.0 of the puppetlabs-mysql module we get the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Mysql::Db[icinga2]:
parameter 'tls_options' expects a value of type Undef or Array, got String (file: /etc/puppetlabs/code/environments/dev/modules/icinga/manifests/database.pp, line: 94) on node X

Expected Behavior

In version v13.2.0 you added the type Optional[Array[String[1]]] to the parameter tls_options, which breaks one of the modules we use (puppet-icinga) -- this tries to create a MySQL DB using this code:

    $_tls_options = if $tls {
      if $tls =~ String and $tls == 'cert' {
        'X509'
      } else {
        'SSL'
      }
    } else {
      'NONE'
    }

    mysql::db { $db_name:
      tls_options => $_tls_options,
      # shortened for readability
    }

So it writes a string into attribute tls_options of type mysql::db, which does not match the associated type.
But your code in lib/puppet/type/mysql_user.rb seems to still be able to cope with strings, as it creates an array out of a single string:

  newproperty(:tls_options, array_matching: :all) do
    desc 'Options to that set the TLS-related REQUIRE attributes for the user.'
    validate do |value|
      value = [value] unless value.is_a?(Array)
      if value.include?('NONE') || value.include?('SSL') || value.include?('X509')

Environment

  • Module Version v13.2.0
  • Platform Debian 11

Suggested Solution

A possible solution could be to correct the type (untested at the moment):

-Optional[Array[String[1]]]                     $tls_options     = undef,
+Optional[Variant[String[1], Array[String[1]]]] $tls_options     = undef,
janit42 added a commit to janit42/puppetlabs-mysql that referenced this issue Mar 3, 2023
the type of $tls_options has recently been changed to Array in 5131e0f while the code in lib/puppet/type/mysql_user.rb is able to work with it as an Array or a String.

This change allows $tls_options to by a String in addition to Array, which re-establishes compatibility with other modules, like puppet-icinga

Fixes puppetlabs#1539
@janit42
Copy link

janit42 commented Mar 3, 2023

To maybe speed a bugfix up a bit, I've created a pull request #1540 based on Alex suggestion.

@alexbugl
Copy link
Author

alexbugl commented Mar 3, 2023

I tested the fix, and it really solved the bug. :)
Please apply ...

janit42 added a commit to janit42/puppetlabs-mysql that referenced this issue Apr 14, 2023
the type of $tls_options has recently been changed to Array in 5131e0f while the code in lib/puppet/type/mysql_user.rb is able to work with it as an Array or a String.

This change allows $tls_options to by a String in addition to Array, which re-establishes compatibility with other modules, like puppet-icinga

Fixes puppetlabs#1539
@janit42
Copy link

janit42 commented Apr 14, 2023

I've updated the pull request to the current main. Would be really nice to get the bugfix in, unfortunately the fix didn't make it into v13.3.0.

janit42 added a commit to janit42/puppetlabs-mysql that referenced this issue May 25, 2023
the type of $tls_options has recently been changed to Array in 5131e0f while the code in lib/puppet/type/mysql_user.rb is able to work with it as an Array or a String.

This change allows $tls_options to by a String in addition to Array, which re-establishes compatibility with other modules, like puppet-icinga

Fixes puppetlabs#1539
janit42 added a commit to janit42/puppetlabs-mysql that referenced this issue Feb 23, 2024
the type of $tls_options has recently been changed to Array in 5131e0f while the code in lib/puppet/type/mysql_user.rb is able to work with it as an Array or a String.

This change allows $tls_options to by a String in addition to Array, which re-establishes compatibility with other modules, like puppet-icinga

Fixes puppetlabs#1539
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants