Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1917314

Summary: leapp process fails when running the root_scanner actor when it encounters non utf8 filenames
Product: Red Hat Enterprise Linux 7 Reporter: Paul Dwyer <pdwyer>
Component: leapp-repositoryAssignee: Leapp team <leapp-notifications>
Status: CLOSED ERRATA QA Contact: Upgrades and Supportability <upgrades-and-supportability>
Severity: medium Docs Contact:
Priority: low    
Version: 7.9CC: cbesson, fkrska, leapp-notifications, mhecko, mmacura, mmoran, mreznik, pstodulk, snavale, ttuffin
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: leapp-repository-0.17.0-1.el7_9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-09 12:33:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1818088    

Description Paul Dwyer 2021-01-18 09:53:19 UTC
Description of problem:
When filenames containing non utf8 are found during running root_scanner actor leapp errors out.

moving these files out of the way leapp is successful.

Can this situation be handled better and would it be possible to highlight non utf8 characters in filenames have been found.

Version-Release number of selected component (if applicable):
leapp-repository-0.12.0-2.el7_9.noarch 

How reproducible:
Repeatedly when filenames with non utf-8 characters are present.

Steps to Reproduce:
1. Have files with non utf8 characters in "/"
2. Run the leapp upgrade (or as this happens in preupgrade step just run "leapp preupgrade")
3. leapp errors out

Actual results:
Leapp root_scanner actor produces following traceback

leapp.workflow.FactsCollection: Executing actor root_scanner
Process Process-247:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 72, in _do_run
    actor_instance.run(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 335, in run
    self.process(*args)
  File "/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/rootscanner/actor.py", line 27, in process
    self.produce(RootDirectory(items=subdirs))
  File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 359, in produce
    self._messaging.produce(model, self)
  File "/usr/lib/python2.7/site-packages/leapp/messaging/__init__.py", line 192, in produce
    return self._do_produce(model, actor, self._new_data)
  File "/usr/lib/python2.7/site-packages/leapp/messaging/__init__.py", line 210, in _do_produce
    data = json.dumps(model.dump(), sort_keys=True)
  File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 332, in _iterencode_list
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 390, in _iterencode_dict
    yield _encoder(value)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb0 in position 0: invalid start byte


=============================================================================================
Actor root_scanner unexpectedly terminated with exit code: 1 - Please check the above details
=============================================================================================


Expected results:
Better handling of this error and give customer's a hint at what might have triggered this traceback if possible.

Additional info:

Comment 12 Petr Stodulka 2022-08-23 10:09:10 UTC
The issue is fixed in upstream by the following PR:
    https://github.com/oamg/leapp-repository/pull/927

Comment 15 Christophe Besson 2022-09-20 09:27:07 UTC
In the meantime, I just suggested a lighter fix for the last case attached to this BZ

--- /usr/share/leapp-repository/repositories/system_upgrade/common/actors/rootscanner/actor.py.orig	2022-09-20 04:27:19.885768165 -0400
+++ /usr/share/leapp-repository/repositories/system_upgrade/common/actors/rootscanner/actor.py	2022-09-20 04:31:43.832949877 -0400
@@ -19,6 +19,12 @@
     def process(self):
         subdirs = []
         for subdir in os.listdir('/'):
+            try:
+                subdir.encode('latin1')
+            except UnicodeDecodeError:
+                continue
             path = os.path.join('/', subdir)
             if os.path.islink(path):
                 subdirs.append(RootSubdirectory(name=subdir, target=os.readlink(path)))

Comment 18 errata-xmlrpc 2022-11-09 12:33:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (leapp and leapp-repository bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7895