Repository navigation
Fix pyenv.install_pyenv passing user into the python argument - #69682
Merged
Merged
Conversation
install_pyenv() called _check_and_install_python(ret, user), passing the user argument into the "python" positional. With the default user=None this fed None into pyenv.install_python(), which raised a TypeError from re.sub() and made the state error out on every run. Add a dedicated _check_and_install_pyenv() helper (mirroring the rbenv state) that installs pyenv itself, and update install_pyenv() to use it, including correct test-mode reporting. Fixes saltstack#37648
…handling The direct test calls install_pyenv with the user kwarg (the argument a production pyenv.install_pyenv state passes, and the one that was previously misrouted into the python version parameter) and asserts pyenv.is_installed/pyenv.install receive it while install_python, default, and versions are never touched. The inverse test guards against overcorrection by confirming the sibling pyenv.installed state still installs a missing python via pyenv.install_python with user passed as runas.
dwoz
approved these changes
Jul 9, 2026
This branch was previously deployed
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.
What does this PR do?
The pyenv.install_pyenv state ended with
return _check_and_install_python(ret, user), passing the user arg into thepythonpositional of _check_and_install_python; with the default user=None this fed None into modules/pyenv.install_python where re.sub() raised a TypeError, so the state errored on every run. The fix adds a dedicated _check_and_install_pyenv() helper (mirroring the rbenv state) that installs pyenv itself and reports test-mode status correctly, and rewrites install_pyenv() to use it. Verified the updated test fails on the unpatched source (result None / "set to be installed" vs expected True) and passes with the fix.What issues does this PR fix or reference?
Fixes #37648
Previous Behavior
See #37648.
New Behavior
Fix pyenv.install_pyenv passing user into the python argument. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).
Merge requirements satisfied?
Commits signed with GPG?
No