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 1870874

Summary: sos fails when a file to be collected has non-utf 8 characters in file name
Product: Red Hat Enterprise Linux 8 Reporter: roarora
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED WONTFIX QA Contact: Miroslav HradĂ­lek <mhradile>
Severity: low Docs Contact:
Priority: unspecified    
Version: ---CC: agk, bmr, mhradile, plambri, sbradley
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-20 07:27:12 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:

Description roarora 2020-08-20 21:59:35 UTC
Description of problem:

This was encountered while reproducing BZ https://bugzilla.redhat.com/show_bug.cgi?id=1803038 and then creating sosreport.

How reproducible:
Alway

Steps to Reproduce:
1. Create a file with invalid utf-8 characater in file name : 
touch '/etc/yum.repos.d/team'$'\303''_epel.repo' 

2. Generate sosreport and it fails

Actual results:
------------------------------
  Starting 101/101 yum             [Running: selinux systemd vdo yum]
  Finishing plugins              [Running: selinux systemd yum]
  Finishing plugins              [Running: systemd yum]
  Finishing plugins              [Running: yum]

  Finished running plugins

Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 19, in <module>
    main(sys.argv[1:])
  File "/usr/lib/python3.6/site-packages/sos/sosreport.py", line 1373, in main
    sos.execute()
  File "/usr/lib/python3.6/site-packages/sos/sosreport.py", line 1350, in execute
    self.generate_reports()
  File "/usr/lib/python3.6/site-packages/sos/sosreport.py", line 1152, in generate_reports
    fd.write(output)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 956087: surrogates not allowed
[root@rhel8u2-14 ~]# 
------------------------------

Expected results:

sos should work fine

Comment 1 Pavel Moravec 2020-08-21 13:44:23 UTC
Nice catch. And when the file has some content, we see two uncaught exceptions (even on upstream sos):

date > '/etc/yum.repos.d/team'$'\303''_epel.repo' 

python3 bin/sos report -o yum --batch --build

..
  Starting 1/1   yum             [Running: yum]
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib64/python3.6/logging/__init__.py", line 996, in emit
    stream.write(msg)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 81: surrogates not allowed
Call stack:
  File "/usr/lib64/python3.6/threading.py", line 884, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 69, in _worker
    work_item.run()
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/root/sos-master/sos/report/__init__.py", line 963, in collect_plugin
    plug.collect()
  File "/root/sos-master/sos/report/plugins/__init__.py", line 2442, in collect
    self._collect_copy_specs()
  File "/root/sos-master/sos/report/plugins/__init__.py", line 2409, in _collect_copy_specs
    self._log_info("collecting path '%s'" % path)
  File "/root/sos-master/sos/report/plugins/__init__.py", line 601, in _log_info
    self.soslog.info(self._format_msg(msg))
Message: "[plugin:yum] collecting path '/etc/yum.repos.d/team\udcc3_epel.repo'"
Arguments: ()

  Finished running plugins

Traceback (most recent call last):
  File "bin/sos", line 22, in <module>
    sos.execute()
  File "/root/sos-master/sos/__init__.py", line 185, in execute
    self._component.execute()
  File "/root/sos-master/sos/report/__init__.py", line 1338, in execute
    self.generate_reports()
  File "/root/sos-master/sos/report/__init__.py", line 1065, in generate_reports
    fd.write(output)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 734: surrogates not allowed



The root cause is the same in both cases. And it should be the same when sosreport calls a command with non-UTF8 character, like:

modprobe dummy

ip link add 'team'$'\303''_epel.repo' type dummy

python3 bin/sos report -o networking --batch --build
..
(tons of below errors)
..
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib64/python3.6/logging/__init__.py", line 996, in emit
    stream.write(msg)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 87: surrogates not allowed
Call stack:
  File "/usr/lib64/python3.6/threading.py", line 884, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 69, in _worker
    work_item.run()
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/root/sos-master/sos/report/__init__.py", line 963, in collect_plugin
    plug.collect()
  File "/root/sos-master/sos/report/plugins/__init__.py", line 2443, in collect
    self._collect_cmds()
  File "/root/sos-master/sos/report/plugins/__init__.py", line 2416, in _collect_cmds
    self._log_info("collecting output of '%s'" % soscmd.cmd)
  File "/root/sos-master/sos/report/plugins/__init__.py", line 601, in _log_info
    self.soslog.info(self._format_msg(msg))
Message: "[plugin:networking] collecting output of 'ethtool -e team\udcc3_epel.repo'"
Arguments: ()

  Finished running plugins

Traceback (most recent call last):
  File "bin/sos", line 22, in <module>
    sos.execute()
  File "/root/sos-master/sos/__init__.py", line 185, in execute
    self._component.execute()
  File "/root/sos-master/sos/report/__init__.py", line 1338, in execute
    self.generate_reports()
  File "/root/sos-master/sos/report/__init__.py", line 1065, in generate_reports
    fd.write(output)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 931: surrogates not allowed

Comment 3 Pavel Moravec 2021-12-06 21:58:05 UTC
Possible idea of a fix: https://github.com/sosreport/sos/issues/2790

Comment 5 RHEL Program Management 2022-02-20 07:27:12 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.