validate_argument_spec - fix validating the argument spec before using it to validate vars#79657
Draft
s-hertel wants to merge 1 commit intoansible:develfrom
Draft
validate_argument_spec - fix validating the argument spec before using it to validate vars#79657s-hertel wants to merge 1 commit intoansible:develfrom
s-hertel wants to merge 1 commit intoansible:develfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
9bac965 to
2b8745f
Compare
s-hertel
commented
Jan 6, 2023
| ) | ||
| for block in validation_blocks: | ||
| for task in block.block: | ||
| task.implicit = True |
Contributor
Author
There was a problem hiding this comment.
This won't change how the validation task is displayed by default. Callbacks only ignore implicit Tasks (unless they set the attr wants_implicit_tasks), and always get the TaskResults, even from implicit Tasks. https://github.com/ansible/ansible/blob/devel/lib/ansible/executor/task_queue_manager.py#L442-L443
s-hertel
commented
Jan 6, 2023
1 task
a5df33a to
bbeb55c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
bbeb55c to
4ba445b
Compare
4ba445b to
e737139
Compare
e737139 to
a2dad29
Compare
This comment was marked as resolved.
This comment was marked as resolved.
a2dad29 to
8d8ee8d
Compare
8d8ee8d to
9a7709c
Compare
passing it to the ArgumentSpecValidator to prevent unhandled errors during variable validation. Make role argument spec errors non-fatal at runtime. Display a warning and include details with -vvv. Pass ArgumentSpecValidator a pruned argument spec containing the valid portion. Give an error and return argument_spec_errors in the task result for non-implicit validate_argument_spec tasks. Add tests for role argument spec errors and validate_argument_spec argument_spec errors.
9a7709c to
9c9725d
Compare
s-hertel
commented
Mar 16, 2026
| fields.pop(field, None) | ||
|
|
||
| if fields.get('type') in ('list', 'dict') and fields.get('options'): | ||
| validate_argspec(validator, context, fields['options'], errors, prune) |
Contributor
Author
There was a problem hiding this comment.
Note: suboptions can use required_if, mutually_exclusive, etc, so not supporting those for this code path would be a breaking change. Maybe this needs a deprecation period just to be safe. It would be simple just to allow those fields for top level options (instead of only suboptions) to fix the inconsistency, but the plan was to implement a better UX.
This file contains hidden or 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
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.
SUMMARY
add a spec for the spec
This resolves the error in #79624, but replaces it with a warning because
no_login the role's argument spec has no bearing on whether or not the tasks in the role divulge it. The role currently needs to manage things likeno_log/aliasesfor variables itself.Fixes #79624
ISSUE TYPE
COMPONENT NAME
validate_argument_spec