Issue #1478 Avoid validate_legacy deprecation failure on Puppet 8#1479
Issue #1478 Avoid validate_legacy deprecation failure on Puppet 8#1479alex-harvey-z3q wants to merge 2 commits into
Conversation
…ppet 8 Do not call the deprecated stdlib deprecation function from validate_legacy. Under Puppet 8 strict settings this can raise before validate_legacy evaluates the supplied value, which breaks modules that still call validate_legacy.
|
@CLAassistant Note that I changed my GitHub handle from alexharv074 to alex-harvey-z3q which could explain why it shows me as having not accepted the CLA. I've accepted again. |
|
The failing build does not appear related to my PR. |
|
@alex-harvey-z3q : Thanks for putting in this PR. If I'm reading your request correctly, you have a scenario where you are running on strict mode so the deprecation on validate_legacy is causing a full error on other modules. Have you identified which module(s) in your dependency tree are still calling validate_legacy (or the older validate_* functions) directly? If it's something you maintain, updating those modules seems like the more durable fix than patching stdlib's runtime behavior. If it's a third-party module you don't control, perhaps we can get PRs in on those modules to fix their use of a deprecated function.
|
Pass false for the strict-setting flag when validate_legacy calls the stdlib deprecation helper. This preserves the deprecation warning for module maintainers, while preventing Puppet strict mode from turning the warning into a hard failure before validation runs.
|
@jst-cyr Yes I see your point. How is this updated version of the PR that keeps the E.g. lib/puppet/functions/validate_legacy.rb (line 55) I will also trace the dependency tree that is still calling |
|
Given these functions where deprecated in 9.0.0, I would have expected them to be removed in 10.0.0 (but they have not). I really do not think that making them less "harmful" is a move in the right direction. |
I have different expectations because this is enterprise software. I would expect enterprise software not to have bugs in it, and I would expect the maintainers of enterprise software to understand that enterprises move slowly. |
By removing the function, you make it harder for people to upgrade to newer stdlib. |
cvquesty
left a comment
There was a problem hiding this comment.
I'm with Alex fisher... we do need to make attempts to keep the barrier lower and the file changes nominal if we can. I think it's important to realize, as mentioned, that we're all volunteers but at the same time this project exists because the puppet folks couldn't keep momentum nor get to the really necessary updates and changes in a timely fashion largely due to blast radius, being overwhelmed when there are indeed several changes that need to happen, thus they did nothing (or next to it...or moved painfully slow)
The conversation around appropriateness for a purpose is important, though. we can't prefer one over the other, and have to strike a medium balance here in that yes, we need to see these as enterprise software but at the same time, there is a mechanism to duplicate and expand on forge modules that are poor or not meeting one's needs. The validate functions have been gone for quite some time now (3 years), but this represents 10 releases. I think they can safely be let go now.
|
My apologies, been out of office and this conversation took off and I'm getting caught up here. I see an approval on the changes here, but the conversation seems to indicate that we SHOULDN'T be removing deprecation warnings. From my view, I agree that we should keep these deprecated and then remove them completely in the next major version (it was not done in stdlib 10 to keep things stable for that release). So it seems to me that the correct fix for the situation that @alex-harvey-z3q finds themself into is updating the references to the old validate functions instead of changing stdlib to avoid strict mode errors? |
|
@jst-cyr Thanks, and we already agreed that we should not remove the deprecation warning. That is not what the updated PR is doing, and that is not what the conversation above is about. The PR still calls the stdlib I have updated the PR description to make that clearer and added links to all of the (many) existing stdlib compatibility shims that already use the same |
|
@alex-harvey-z3q : Thank you, I definitely misread the flow of the conversation while trying to catch up. I see now the changes have been updated to match with other deprecations in the module instead of the original changes that had proposed removing the deprecation warning altogether. I had already added the PR into the list for engineering review, but given that the change has been reduced and scope is minimal and resolves a bug I've boosted it a bit versus some other changes in the backlog. |
|
Thank you I appreciate it @jst-cyr ! |
Summary
Fixes the deprecated
validate_legacy()function so that it emits a deprecation warning, as intended, and no longer lets Puppet's globalstrictsetting turn that warning into a catalog failure.Note that the stdlib
deprecationhelper accepts an optional fourth argument nameduse_strict_setting. It defaults totrue, which means the helper followsPuppet.settings[:strict]::warninglogs a warning:errorraises an error:offsuppresses the messageThis PR changes the
validate_legacy()call to passfalsefor that argument:With
use_strict_settingset tofalse,validate_legacy()still calls the deprecation helper and still emits the warning, but the warning is always handled as a soft deprecation warning instead of being promoted to an error under strict mode.That preserves the migration signal for module maintainers while avoiding a hard failure before
validate_legacy()can perform its type assertion.Existing stdlib precedent
This matches the pattern already used by stdlib's generated unnamespaced compatibility shims. Those functions are deprecated, emit a deprecation warning, and then delegate to the namespaced replacement while passing
falsetodeprecation()so the compatibility path remains usable under strict mode.Existing examples include:
mergeensure_packagesbatch_escapefqdn_rand_stringfqdn_rotatehas_interface_withhas_ip_addresshas_ip_networkos_version_gteparsehoconpowershell_escapeseeded_randseeded_rand_stringshell_escapeto_jsonto_json_prettyto_pythonto_rubyto_tomlto_yamltype_ofvalidate_domain_namevalidate_email_addressThe specs have also been updated to assert that
validate_legacy()continues to call the deprecation helper withuse_strict_settingset tofalse.Checklist