You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(PUP-12026) Change non-literal type check to deprecation warning
Previously, the ILLEGAL_NONLITERAL_PARAMETER_TYPE issue was under control of the
`strict` setting. Since `strict` defaults to `error`, `puppet parser validate`
logged an error message and exited non-zero for non-literal types such as
`Integer[0, 60*24]`
In order to gradually phase out non-literal parameter types, this commit changes
the issue to be a deprecation. When parsing and validating puppet code a warning
is now logged, regardless of `strict`, and it exits with 0:
Warning: The parameter '$i' must be a literal type, not a ...
(file: /etc/puppetlabs/code/environments/production/manifests/site.pp,
line: 2, column: 19)
As a result of this change, the ClassInfoService error does not include locator
information in the error hash:
{"error":"The parmeter '$i' is invalid: The expression <60*24> is not a valid type specification"}
But the location information is included in the deprecation warning logged on
the server.
All language deprecation warnings can already be disabled via the
`disable_warnings=deprecations` setting. In a future major release, the
non-literal type issue will be converted to an error.
This pattern follows how we handled the most recent language checks:
ILLEGAL_DEFINITION_LOCATION: see 6e7835b, 44c4ea0 and 81e61de
ILLEGAL_TOP_CONSTRUCT_LOCATION: see 5661509 and 81e61de
(cherry picked from commit 86a8c14)
expect(@logs).toinclude(an_object_having_attributes(message: "The parameter '$bad_int' must be a literal type, not a Puppet::Pops::Model::AccessExpression"))
522
-
expect(@logs).toinclude(an_object_having_attributes(message: "The parameter '$double_brackets' must be a literal type, not a Puppet::Pops::Model::AccessExpression"))
521
+
expect(@logs).tohave_matching_log_with_source(/The parameter '\$bad_int' must be a literal type, not a Puppet::Pops::Model::AccessExpression/,"#{code_dir}/non_literal.pp",1,37)
522
+
expect(@logs).tohave_matching_log_with_source(/The parameter '\$double_brackets' must be a literal type, not a Puppet::Pops::Model::AccessExpression/,"#{code_dir}/non_literal_2.pp",1,44)
523
523
end
524
524
525
525
it"errors in strict mode if non-literal class parameter is given"do
expect(@logs).tohave_matching_log_with_source(/The parameter '\$bad_int' must be a literal type, not a Puppet::Pops::Model::AccessExpression/,"#{code_dir}/non_literal.pp",1,37)
530
+
expect(@logs).tohave_matching_log_with_source(/The parameter '\$double_brackets' must be a literal type, not a Puppet::Pops::Model::AccessExpression/,"#{code_dir}/non_literal_2.pp",1,44)
531
+
529
532
expect(result).toeq({
530
533
"production"=>{
531
534
"#{code_dir}/non_literal.pp"=>
532
-
{:error=>"The parameter '$bad_int' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: #{code_dir}/non_literal.pp, line: 1, column: 37)"},
535
+
{:error=>"The parameter '\$bad_int' is invalid: The expression <1-3> is not a valid type specification."},
533
536
"#{code_dir}/non_literal_2.pp"=>
534
-
{:error=>"The parameter '$double_brackets' must be a literal type, not a Puppet::Pops::Model::AccessExpression (file: #{code_dir}/non_literal_2.pp, line: 1, column: 44)"}
537
+
{:error=>"The parameter '\$double_brackets' is invalid: The expression <Optional[[String]]> is not a valid type specification."}
0 commit comments