-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
(PUP-11981) Syntactically incorrect types cause nil in Puppet::InfoService::ClassInformationService #9190
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AriaXLi
force-pushed
the
PUP-11981
branch
2 times, most recently
from
January 11, 2024 21:12
b46508d
to
1a2c4b7
Compare
jenkins please test this |
|
AriaXLi
force-pushed
the
PUP-11981
branch
3 times, most recently
from
January 11, 2024 22:30
97d848d
to
00d0414
Compare
AriaXLi
changed the title
(PUP-11981) WIP
(PUP-11981) Syntactically incorrect types cause nil in Puppet::InfoService::ClassInformationService
Jan 11, 2024
joshcooper
reviewed
Jan 16, 2024
joshcooper
reviewed
Jan 16, 2024
This commit adds logic to validate class parameters are literal and provides a descriptive warning if parameter(s) are not literal, adds QualifiedReference and AccessExpression as a valid literal values & updates spec tests to check for more cases of invalid class parameters and any that broke as a result of the changes. The logic to validate class parameters is done in internal_check_parameter_type_literal method where the appropriate literal method is called on each parameter. There are different literal methods for each literal object/type [1]. For example if the parameter is String type, then literal_LiteralString is called. If a parameter is found to be not literal, then a :not_literal will be thrown & warning message with the invalid class parameter and its type will be printed. QualifiedReference is considered literal since it is a literal reference, however, there is a possibility it could be a faulty dangling reference that doesn't reference anything. AccessExpresions are anything with the Access Operator ([ ]) such as Optional[String] or Variant[Boolean, Float] [2]. Since these are valid class parameters, AccessExpressions are also considered literal. The logic to add QualifiedReference & AccessExpression as valid literal values is done in the literal_QualifiedReference & literal_AccessExpression methods. The literal_AccessExpression works by validating each key in the expression is literal. The literal_QualifiedReference method looks at o.value, similar to other existing literal methods like literal_LiteralString. [1] http://puppet-on-the-edge.blogspot.com/2014/02/puppet-internals-polymorphic-dispatch.html [2] https://github.com/puppetlabs/puppet-specifications/blob/master/language/expressions.md#assignment-operator For more information on this issue, see puppetlabs#9140
joshcooper
approved these changes
Jan 17, 2024
@AriaXLi since this issue was originally encountered in the ClassInfoService, could you add a test to somewhere in puppet/spec/unit/info_service_spec.rb Lines 479 to 524 in 050c7b4
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit adds logic to validate class parameters are literal and provides a descriptive warning if parameter(s) are not literal, adds
QualifiedReference
andAccessExpression
as a valid literal values & updates spec tests to check for more cases of invalid class parameters and any that broke as a result of the changes.The logic to validate class parameters is done in internal_check_parameter_type_literal method where the appropriate literal method is called on each parameter. There are different literal methods for each literal object/type [1]. For example if the parameter is String type, then
literal_LiteralString
is called. If a parameter is found to be not literal, then a:not_literal
will be thrown & warning message with the invalid class parameter and its type will be printed.QualifiedReference
is considered literal since it is a literal reference, however, there is a possibility it could be a faulty dangling reference that doesn't reference anything.AccessExpresions
are anything with theAccess Operator
([ ]) such as Optional[String] or Variant[Boolean, Float] [2]. Since these are valid class parameters,AccessExpressions
are also considered literal.The logic to add
QualifiedReference
&AccessExpression
as valid literal values is done in the literal_QualifiedReference & literal_AccessExpression methods. Theliteral_AccessExpression
method works by validating each key in the expression is literal. Theliteral_QualifiedReference
method looks at o.value, similar to other existing literal methods likeliteral_LiteralString
.[1] http://puppet-on-the-edge.blogspot.com/2014/02/puppet-internals-polymorphic-dispatch.html
[2] https://github.com/puppetlabs/puppet-specifications/blob/master/language/expressions.md#assignment-operator
For more information on this issue, see #9140