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.
validate_legacyfails catalog compilation under Puppet 8 strict deprecation handlingSummary
validate_legacy()still calls stdlib'sdeprecation()helper directly. Under Puppet 8 / OpenVox 8, wherestrict=erroris the default behaviour, this deprecation call can raise a hard evaluation error beforevalidate_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:
deprecationfunction and Puppet 8 are not compatible #1391: Thedeprecationfunction and Puppet 8 are not compatibleDeprecationfunction cause catalog compilation to fail ifstrictsetting is set toerror#1373: Calls toDeprecationfunction cause catalog compilation to fail ifstrictsetting is set toerrorstrictsetting when calling function without namespace #1377: Ignore Puppet'sstrictsetting when calling function without namespaceuse_strict_settingparameter todeprecationfunction #1378: Adduse_strict_settingparameter todeprecationfunctionThe previous fixes addressed namespaced/non-namespaced function shims, but
validate_legacy()still has a directdeprecation()call and can still fail.Affected Code
Current
validate_legacy()callsdeprecation()before doing the assertion:Expected Behaviour
validate_legacy()should preserve its legacy compatibility behaviour:validate_legacy()is deprecated should not itself make catalog compilation fail under Puppet 8Actual Behaviour
The direct call to stdlib
deprecation()can raise under Puppet 8 strict deprecation handling, so otherwise valid catalogs fail beforevalidate_legacy()evaluates the supplied value.