Skip to content

Fix YumPackageManager false positive when package name contains "errno" - #393

Open
yashnap wants to merge 5 commits into
masterfrom
icm_fix
Open

yashnap wants to merge 5 commits into
masterfrom
icm_fix

Conversation

@yashnap

@yashnap yashnap commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

What's happening: RHEL 9.8 VMs log ERROR:[YPM] Customer Environment Error: Not a known error , but patch assessment is actually succeeding ( TaskStatus=succeeded , updates reported correctly).

What customer sees:
image

Root cause:
YPM's error handling checks the package manager output for the strings "Error" or "Errno". One of the packages returned by the command is perl-Errno, which contains the substring "Errno". As a result, a normal check-update or list installed output is incorrectly treated as an error. The output does not match any known error pattern, so YPM logs:
Customer Environment Error: Not a known error...
This is a false positive caused by a package name and not an actual customer environment issue.

Fix : Update the Exception block to exclude the package when checking for errors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The exclusion can hide genuine errors when the output also contains perl-Errno, and the new test does not detect the original behavior.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Prevents perl-Errno package names from triggering Yum error mitigation.

Changes:

  • Excludes perl-Errno from error detection.
  • Adds a regression test for the false positive.
File Description
src/​core/​src/​package_managers/​YumPackageManager.py Adjusts Yum error detection.
src/​core/​tests/​Test_YumPackageManager.py Adds regression coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/core/src/package_managers/YumPackageManager.py Outdated
Comment thread src/core/tests/Test_YumPackageManager.py
@kjohn-msft Koshy John (kjohn-msft) added the bug Something isn't working label Oct 6, 2026
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.06%. Comparing base (3066008) to head (8851d54).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #393      +/-   ##
==========================================
+ Coverage   95.03%   95.06%   +0.03%     
==========================================
  Files         113      113              
  Lines       21994    22013      +19     
==========================================
+ Hits        20901    20926      +25     
+ Misses       1093     1087       -6     
Flag Coverage Δ
python27 95.03% <100.00%> (+<0.01%) ⬆️
python312 95.03% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rane-rajasi Rajasi Rane (rane-rajasi) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments inline.

self.assertTrue(package_manager)

mitigation_attempted = {'called': False}
def record_call(output):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define mock functions outside similar to other test structures

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

package_manager = self.container.get('package_manager')
self.assertTrue(package_manager)

package_manager.check_known_issues_and_attempt_fix = lambda output: self.fail("perl-Errno must not enter error mitigation")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review whether we use lambda functions, IIRC we use mock functions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@rane-rajasi Rajasi Rane (rane-rajasi) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments inline.

return ['Red Hat Enterprise Linux Server', '8', 'Ootpa']

def mock_check_known_issues_and_attempt_fix_record_call(self, output):
self.check_known_issues_and_attempt_fix_called = True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a class level variable i.e. ideally defined in init() or for the purpose of UTs, defined in setUp()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the mock since none of the added tests now uses it


package_manager.check_known_issues_and_attempt_fix = backup_check_known_issues_and_attempt_fix

self.assertTrue(self.check_known_issues_and_attempt_fix_called)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primary assert should not be on whether a mock function is called, this can be an additional assert. However, the primary one should always be on the expected outcome, say the status reported, etc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the assert


self.check_known_issues_and_attempt_fix_called = False
backup_check_known_issues_and_attempt_fix = package_manager.check_known_issues_and_attempt_fix
package_manager.check_known_issues_and_attempt_fix = self.mock_check_known_issues_and_attempt_fix_record_call

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mock check_known_issues_and_attempt_fix () in both of these tests? It is simply using the error message to verify against known errors and attempts a fix if a match is found. Which here will not match, so no fix is attempted. Non mocking will actually test the complete functionality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the mock usage.


self.check_known_issues_and_attempt_fix_called = False
backup_check_known_issues_and_attempt_fix = package_manager.check_known_issues_and_attempt_fix
package_manager.check_known_issues_and_attempt_fix = self.mock_check_known_issues_and_attempt_fix_record_call

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question on why this is mocked? There is also an existing test with the similar error (barring perl-Errno) which runs without a mock: test_auto_issue_mitigation_when_retries_are_exhausted_raise_exception_disabled()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt notice the other test. I've updated to have the same pattern and not use mock

Comment thread src/core/tests/Test_YumPackageManager.py Fixed
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants