Fix module.run: positional arg for defaulted param raises 'multiple values' - #70083
Open
HarnageaGabriel wants to merge 1 commit into
Open
Fix module.run: positional arg for defaulted param raises 'multiple values'#70083HarnageaGabriel wants to merge 1 commit into
HarnageaGabriel wants to merge 1 commit into
Conversation
…alues" salt.utils.functools.call_function() pre-seeded function_kwargs with every defaulted parameter's default value, then appended positionally-passed values to function_args without removing the corresponding key from function_kwargs. A parameter filled positionally that also has a default (e.g. size in test.rand_str) ended up passed both positionally and as a stale keyword default, raising "got multiple values for argument". Strip argspec-matched keyword defaults from function_kwargs once function_args is finalized, before merging in explicit kwargs. Fixes saltstack#69919
HarnageaGabriel
force-pushed
the
fix-module-run-positional-default-arg
branch
from
August 19, 2026 19:33
ebdb9d5 to
ab6a576
Compare
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
Fixes #69919.
module.run(and anything else routed throughsalt.utils.functools.call_function()) crashed withgot multiple values for argument 'size'when a positional argument was passed for a target-function parameter that also has a default value:Root cause:
call_function()pre-seedsfunction_kwargswith every defaulted parameter's default value up front, then appends raw positional list items tofunction_argswithout removing the corresponding key fromfunction_kwargs. A parameter satisfied positionally that also happens to have a default (e.g.sizeintest.rand_str) ended up passed both positionally and via its stale default keyword — a genuineTypeError-equivalent collision.Fix: once
function_argsis finalized, strip anyargspec.argsentries already covered positionally out offunction_kwargsbefore merging in explicit kwargs and dict-style keyword items from the args list. This keeps the "kwargs win last" and missing-argument validation semantics intact.Test plan
test_call_function_positional_arg_with_defaultintests/pytests/unit/states/test_module.py, reproducing the exact issue scenario.pytest tests/pytests/unit/states/test_module.py -v— 24 passed.pytest tests/pytests/unit/modules/test_mine.py -v(other caller ofcall_function) — 18 passed, no regressions.🤖 Generated with Claude Code