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 1850624 - Uncaught JSONDecodeError when content_access.json is empty and registering to Satellite6
Summary: Uncaught JSONDecodeError when content_access.json is empty and registering to...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: William Poteat
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-06-24 15:08 UTC by Pavel Moravec
Modified: 2023-12-15 18:16 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 13:32:41 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 2351 0 None closed 1850624: Uncaught JSONDecodeError when content_access.json is empty a… 2021-02-02 10:04:33 UTC
Github candlepin subscription-manager pull 2352 0 None closed 1850624: Uncaught JSONDecodeError when content_access.json is empty 2021-02-02 10:04:33 UTC
Red Hat Knowledge Base (Solution) 5207161 0 None None None 2020-07-07 10:48:26 UTC

Description Pavel Moravec 2020-06-24 15:08:26 UTC
Description of problem:
Customer scenario:

/var/lib/rhsm/cache/content_access.json file is empty (due to whatever reason; optionally a malformed JSON content there).

Then an attempt to register to Satellite6.7 fails with an uncaught json.decoder.JSONDecodeError exception.

Registering to rhsm.redhat.com or to Satellite 6.6 works fine. Simply, Sat6.7 triggers the specific call flow that fetches some certs for locally missing serials.


Version-Release number of selected component (if applicable):
- subscription-manager-1.23.8-35.el8.x86_64
- any older version affected as well (also RHEL7, probably not worth to fix it there?)


How reproducible:
100%


Steps to Reproduce:
1.
rm -f /var/lib/rhsm/cache/content_access.json
touch /var/lib/rhsm/cache/content_access.json

2. register the system to Satelite6.7 by either way (via AK, via user/password, whatever)


Actual results:
The registration fails at the end with:

Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 11, in <module>
    load_entry_point('subscription-manager==1.23.8', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2918, in main
    ret = CLI.main(self)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 506, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 1400, in _do_command
    self.entcertlib.update()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/certlib.py", line 32, in update
    self.report = self.locker.run(self._do_update)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/certlib.py", line 18, in run
    return action()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/entcertlib.py", line 42, in _do_update
    return action.perform()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/entcertlib.py", line 141, in perform
    self.content_access_hook()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/entcertlib.py", line 194, in content_access_hook
    update_data = self.content_access_cache.check_for_update()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cache.py", line 685, in check_for_update
    data = json.loads(self.read())
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


Expected results:
No such uncaught exception.


Additional info:
The "json.loads(self.read())" should be wrapped in some catch block, I expect.

Comment 1 Pavel Moravec 2020-06-26 08:34:43 UTC
The problem was noticed when registering a system against Satellite 6.6 as well.

I am able to reproduce it against my Sat6.7 only. Registration to my Sat6.6 works well - maybe the call flow / error depends on some Satellite setting..?

Comment 8 Craig Donnelly 2020-12-01 04:32:35 UTC
Testing against RHEL-8.4.0-20201130.n.1:

[root@dhcp-8-29-107 ~]# rpm -q subscription-manager
subscription-manager-1.28.6-1.el8.x86_64

>> Reproducing issue (subscription-manager-1.26.20-1.el8_2.x86_64):

[root@dhcp-8-29-107 yum.repos.d]# subscription-manager unregister
Unregistering from: sat68:443/rhsm
System has been unregistered.
[root@dhcp-8-29-107 yum.repos.d]# rm /var/lib/rhsm/cache/content_access.json 
rm: remove regular file '/var/lib/rhsm/cache/content_access.json'? y
[root@dhcp-8-29-107 yum.repos.d]# touch /var/lib/rhsm/cache/content_access.json
[root@dhcp-8-29-107 yum.repos.d]# subscription-manager register
Registering to: sat68:443/rhsm
Username: admin
Password: 
The system has been registered with ID: 99e9521c-f314-4090-a8d9-1e21a8fc9b98
The registered system name is: client
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 11, in <module>
    load_entry_point('subscription-manager==1.26.20', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/scripts/subscription_manager.py", line 87, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 2996, in main
    ret = CLI.main(self)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 536, in main
    return_code = self._do_command()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/managercli.py", line 1434, in _do_command
    self.entcertlib.update()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/certlib.py", line 32, in update
    self.report = self.locker.run(self._do_update)
  File "/usr/lib64/python3.6/site-packages/subscription_manager/certlib.py", line 18, in run
    return action()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/entcertlib.py", line 42, in _do_update
    return action.perform()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/entcertlib.py", line 141, in perform
    self.content_access_hook()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/entcertlib.py", line 194, in content_access_hook
    update_data = self.content_access_cache.check_for_update()
  File "/usr/lib64/python3.6/site-packages/subscription_manager/cache.py", line 696, in check_for_update
    data = json.loads(self.read())
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[root@dhcp-8-29-107 yum.repos.d]# subscription-manager unregister
Unregistering from: sat68:443/rhsm
System has been unregistered.

>> Updating to nightly version:

[root@dhcp-8-29-107 yum.repos.d]# yum update subscription-manager
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:48 ago on Mon 30 Nov 2020 11:25:32 PM EST.
Dependencies resolved.
==================================================================================================================================
 Package                                         Architecture    Version                Repository                           Size
==================================================================================================================================
Upgrading:
 dnf-plugin-subscription-manager                 x86_64          1.28.6-1.el8           rhel-8-nightly-baseos-rpms          290 k
 python3-subscription-manager-rhsm               x86_64          1.28.6-1.el8           rhel-8-nightly-baseos-rpms          363 k
 subscription-manager                            x86_64          1.28.6-1.el8           rhel-8-nightly-baseos-rpms          1.1 M
 subscription-manager-rhsm-certificates          x86_64          1.28.6-1.el8           rhel-8-nightly-baseos-rpms          263 k

Transaction Summary
==================================================================================================================================
Upgrade  4 Packages

Total download size: 2.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): dnf-plugin-subscription-manager-1.28.6-1.el8.x86_64.rpm                                    1.1 MB/s | 290 kB     00:00    
(2/4): python3-subscription-manager-rhsm-1.28.6-1.el8.x86_64.rpm                                  1.3 MB/s | 363 kB     00:00    
(3/4): subscription-manager-1.28.6-1.el8.x86_64.rpm                                               2.5 MB/s | 1.1 MB     00:00    
(4/4): subscription-manager-rhsm-certificates-1.28.6-1.el8.x86_64.rpm                             1.2 MB/s | 263 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------
Total                                                                                             4.2 MB/s | 2.0 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                          1/1 
  Running scriptlet: subscription-manager-rhsm-certificates-1.28.6-1.el8.x86_64                                               1/1 
  Upgrading        : subscription-manager-rhsm-certificates-1.28.6-1.el8.x86_64                                               1/8 
  Upgrading        : python3-subscription-manager-rhsm-1.28.6-1.el8.x86_64                                                    2/8 
  Upgrading        : dnf-plugin-subscription-manager-1.28.6-1.el8.x86_64                                                      3/8 
  Upgrading        : subscription-manager-1.28.6-1.el8.x86_64                                                                 4/8 
warning: /etc/rhsm/rhsm.conf created as /etc/rhsm/rhsm.conf.rpmnew

  Running scriptlet: subscription-manager-1.28.6-1.el8.x86_64                                                                 4/8 
chmod: cannot access '/etc/pki/entitlement/*.pem': No such file or directory

  Running scriptlet: subscription-manager-1.26.20-1.el8_2.x86_64                                                              5/8 
  Cleanup          : subscription-manager-1.26.20-1.el8_2.x86_64                                                              5/8 
  Running scriptlet: subscription-manager-1.26.20-1.el8_2.x86_64                                                              5/8 
  Cleanup          : python3-subscription-manager-rhsm-1.26.20-1.el8_2.x86_64                                                 6/8 
  Cleanup          : subscription-manager-rhsm-certificates-1.26.20-1.el8_2.x86_64                                            7/8 
  Cleanup          : dnf-plugin-subscription-manager-1.26.20-1.el8_2.x86_64                                                   8/8 
  Running scriptlet: dnf-plugin-subscription-manager-1.26.20-1.el8_2.x86_64                                                   8/8 
  Verifying        : dnf-plugin-subscription-manager-1.28.6-1.el8.x86_64                                                      1/8 
  Verifying        : dnf-plugin-subscription-manager-1.26.20-1.el8_2.x86_64                                                   2/8 
  Verifying        : python3-subscription-manager-rhsm-1.28.6-1.el8.x86_64                                                    3/8 
  Verifying        : python3-subscription-manager-rhsm-1.26.20-1.el8_2.x86_64                                                 4/8 
  Verifying        : subscription-manager-1.28.6-1.el8.x86_64                                                                 5/8 
  Verifying        : subscription-manager-1.26.20-1.el8_2.x86_64                                                              6/8 
  Verifying        : subscription-manager-rhsm-certificates-1.28.6-1.el8.x86_64                                               7/8 
  Verifying        : subscription-manager-rhsm-certificates-1.26.20-1.el8_2.x86_64                                            8/8 
Installed products updated.

Upgraded:
  dnf-plugin-subscription-manager-1.28.6-1.el8.x86_64          python3-subscription-manager-rhsm-1.28.6-1.el8.x86_64              
  subscription-manager-1.28.6-1.el8.x86_64                     subscription-manager-rhsm-certificates-1.28.6-1.el8.x86_64         

Complete!
(reverse-i-search)`/': touch /var/lib/rhsm/cache^Content_access.json
[root@dhcp-8-29-107 yum.repos.d]# rm /var/lib/rhsm/cache/content_access.json 
rm: remove regular empty file '/var/lib/rhsm/cache/content_access.json'? y
[root@dhcp-8-29-107 yum.repos.d]# touch /var/lib/rhsm/cache/content_access.json
[root@dhcp-8-29-107 yum.repos.d]# subscription-manager register
Registering to: sat68:443/rhsm
Username: admin
Password: 
The system has been registered with ID: fcf6a60c-7e56-47f8-945a-d03cece7f3b8
The registered system name is: client

>> No traceback, verified.

Comment 13 errata-xmlrpc 2021-05-18 13:32:41 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 (subscription-manager 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-2021:1575


Note You need to log in before you can comment on or make changes to this bug.