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
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
+
521
524
expect(result).toeq({
522
525
"production"=>{
523
526
"#{code_dir}/non_literal.pp"=>
524
-
{: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)"},
527
+
{:error=>"The parameter '\$bad_int' is invalid: The expression <1-3> is not a valid type specification."},
525
528
"#{code_dir}/non_literal_2.pp"=>
526
-
{: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)"}
529
+
{:error=>"The parameter '\$double_brackets' is invalid: The expression <Optional[[String]]> is not a valid type specification."}
0 commit comments