Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] (PUP-12026) Change non-literal type check to deprecation warning #9307

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

joshcooper
Copy link
Contributor

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)

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)
@joshcooper joshcooper requested a review from a team as a code owner April 1, 2024 23:18
@AriaXLi AriaXLi merged commit 40d8dbf into puppetlabs:7.x Apr 1, 2024
12 checks passed
@joshcooper joshcooper added the bug Something isn't working label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants