puppetlabs / puppetlabs/puppetlabs-stdlib
`validate_legacy` fails catalog compilation under Puppet 8 strict deprecation handling
Nobody has claimed this yet.
- 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
deprecationfunction and Puppet 8 are not compatible - #1373: Calls to
Deprecationfunction cause catalog compilation to fail ifstrictsetting is set toerror - #1377: Ignore Puppet's
strictsetting when calling function without namespace - #1378: Add
use_strict_settingparameter todeprecationfunction
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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