Skip to content

validate_legacy fails catalog compilation under Puppet 8 strict deprecation handling #1478

Description

@alex-harvey-z3q

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions