fix: handle ansible encoding errors and update rocky9 package assertion#820
Merged
philpep merged 1 commit intoJun 2, 2026
Conversation
- ansible.py: handle ansible error responses containing only 'msg' key (no stdout/stderr) to avoid KeyError when commands fail at transport layer due to encoding issues - test_backends.py: update encoding test to accept both old-style ansible error messages and new surrogate-rejection errors from newer ansible - test_modules.py: update rocky linux 9 openssh-server version prefix from 8. to 9. (new image ships openssh-server 9.9p1)
philpep
approved these changes
Jun 2, 2026
Contributor
|
Merged, thanks! |
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 CI failures in the
build (py311)job:1. Handle Ansible encoding errors gracefully (
testinfra/backend/ansible.py)When Ansible fails to run a command (e.g., due to UTF-8 surrogate encoding issues), it returns a response with only a
msgkey and nostdout/stderr. Previously this caused aKeyError: 'stdout'. Now the code:module_stdout(new ansible format)stdout(backward compat)msgfor error responses, placed instderr.get("rc", 1)sincercmay also be missing2. Make encoding test resilient to Ansible version differences (
test/test_backends.py)The
test_encoding[ansible://debian_bookworm?force_ansible=True]test now accepts either the old-stylelserror message with surrogates (older ansible) or the new surrogate-rejection transport error from newer ansible versions. Also assertscmd.failed is True.3. Update Rocky Linux 9 package version expectation (
test/test_modules.py)The rocky linux 9 docker image now ships
openssh-server 9.9p1instead of 8.x. Updated version prefix from"8."to"9.".Fixes CI run: https://github.com/pytest-dev/pytest-testinfra/actions/runs/26749425227