Skip to content

Fix pyenv.install_pyenv passing user into the python argument - #69682

Merged
dwoz merged 3 commits into
saltstack:3006.xfrom
ggiesen:fix-37648-pyenv-install
Jul 9, 2026
Merged

dwoz merged 3 commits into
saltstack:3006.xfrom
ggiesen:fix-37648-pyenv-install

Conversation

@ggiesen

@ggiesen ggiesen commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

The pyenv.install_pyenv state ended with return _check_and_install_python(ret, user), passing the user arg into the python positional 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?

  • Tests written/updated
  • Changelog

Commits signed with GPG?

No

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
dwoz merged commit a450794 into saltstack:3006.x Jul 9, 2026
1310 of 1340 checks passed

This branch was previously deployed

1 inactive deployment
ci — 7378c225 Deployed Jul 7, 2026 by dwoz via Build Onedir Packages / macOS (arm64) #25386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants