puppetlabs / puppetlabs/puppetlabs-stdlib

`validate_legacy` fails catalog compilation under Puppet 8 strict deprecation handling

Open Beginner friendly
#1,478 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bugfix
Dominant language
Ruby
Stars
349
Forks
573
Avg merge
3d 3h
Merged PRs (30d)
1

Description

validate_legacy fails catalog compilation under Puppet 8 strict deprecation handling

Summary

validate_legacy() still calls stdlib's deprecation() helper directly. Under Puppet 8 / OpenVox 8, where strict=error is the default behaviour, this deprecation call can raise a hard evaluation error before validate_legacy() performs its actual type assertion.

This appears to be an uncovered validate_legacy() instance of the deprecation/Puppet 8 compatibility issue tracked in #1391.

Related issues and PRs:

  • #1391: The deprecation function and Puppet 8 are not compatible
  • #1373: Calls to Deprecation function cause catalog compilation to fail if strict setting is set to error
  • #1377: Ignore Puppet's strict setting when calling function without namespace
  • #1378: Add use_strict_setting parameter to deprecation function

The previous fixes addressed namespaced/non-namespaced function shims, but validate_legacy() still has a direct deprecation() call and can still fail.

Affected Code

Current validate_legacy() calls deprecation() before doing the assertion:

def validate_legacy(_scope, target_type, _function_name, value, *_prev_args)
  call_function('deprecation', 'validate_legacy', 'This method is deprecated, please use Puppet data types to validate parameters')
  if assert_type(target_type, value)
    # "Silently" passes
  else
    inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value)
    error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch("validate_legacy(#{target_type}, ...)", target_type, inferred_type)
    call_function('fail', error_msg)
  end
end

Expected Behaviour

validate_legacy() should preserve its legacy compatibility behaviour:

  • valid values should pass silently
  • invalid values should fail with the existing type mismatch error
  • the fact that validate_legacy() is deprecated should not itself make catalog compilation fail under Puppet 8

Actual Behaviour

The direct call to stdlib deprecation() can raise under Puppet 8 strict deprecation handling, so otherwise valid catalogs fail before validate_legacy() evaluates the supplied value.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the validate_legacy implementation shown in the issue and reproduce catalog compilation under Puppet 8 or OpenVox 8 with strict=error. Verify that valid values compile without a deprecation failure and invalid values still produce the existing type mismatch error.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.