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 1435771 - RHSM1DBusException: com.redhat.RHSM1.Error: UnboundLocalError: local variable 'data' referenced before assignment
Summary: RHSM1DBusException: com.redhat.RHSM1.Error: UnboundLocalError: local variable...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager
Version: 7.4
Hardware: Unspecified
OS: Unspecified
high
low
Target Milestone: rc
: ---
Assignee: Chris Snyder
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-24 17:39 UTC by John Sefler
Modified: 2017-08-01 19:21 UTC (History)
4 users (show)

Fixed In Version: subscription-manager-1.19.9-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 19:21:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 1578 0 None None None 2017-04-06 20:45:33 UTC
Red Hat Product Errata RHBA-2017:2083 0 normal SHIPPED_LIVE python-rhsm and subscription-manager bug fix and enhancement update 2017-08-01 18:14:19 UTC

Description John Sefler 2017-03-24 17:39:41 UTC
Description of problem:
When there is a malformed custom fact or simply an empty custom facts file, a traceback occurs during registration.

This is a regression from RHEL7.3 where a WARNING like the following was written to rhsm.log

[WARNING]  @facts.py:125 - Unable to load custom facts file: /etc/rhsm/facts/empty.facts



Version-Release number of selected component (if applicable):
[root@jsefler-rhel7 ~]# rpm -q subscription-manager python-rhsm
subscription-manager-1.19.4-1.el7.x86_64
python-rhsm-1.19.2-1.el7.x86_64


How reproducible:


Steps to Reproduce:
[root@jsefler-rhel7 ~]# touch /etc/rhsm/facts/empty.facts
[root@jsefler-rhel7 ~]# subscription-manager register
Registering to: jsefler-candlepin.usersys.redhat.com:8443/candlepin
Username: testuser1
Password: 
com.redhat.RHSM1.Error: Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/dbus/service.py", line 707, in _message_cb
    retval = candidate_method(self, *args, **keywords)
  File "<string>", line 2, in GetFacts
  File "/usr/lib/python2.7/site-packages/rhsmlib/dbus/util.py", line 32, in dbus_handle_exceptions
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/rhsmlib/dbus/facts/base.py", line 79, in GetFacts
    results.update(fact_collector.GetFacts())
  File "<string>", line 2, in GetFacts
  File "/usr/lib/python2.7/site-packages/rhsmlib/dbus/util.py", line 32, in dbus_handle_exceptions
    ret = func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/rhsmlib/dbus/facts/base.py", line 43, in GetFacts
    collection = self.facts_collector.collect()
  File "/usr/lib/python2.7/site-packages/rhsmlib/facts/collector.py", line 84, in collect
    facts_dict.update(self.get_all())
  File "/usr/lib/python2.7/site-packages/rhsmlib/facts/host_collector.py", line 85, in get_all
    custom_facts_dict = custom_facts.get_all()
  File "/usr/lib/python2.7/site-packages/rhsmlib/facts/custom.py", line 111, in get_all
    for custom_facts in facts_dir:
  File "/usr/lib/python2.7/site-packages/rhsmlib/facts/custom.py", line 85, in __iter__
    yield CustomFacts.from_json(fact_file.read())
  File "/usr/lib/python2.7/site-packages/rhsmlib/facts/custom.py", line 37, in from_json
    custom_facts.data = data
RHSM1DBusException: com.redhat.RHSM1.Error: UnboundLocalError: local variable 'data' referenced before assignment


Actual results:
 above

Expected results:
 expected a successful register with the following rhsm.log entry
 [WARNING]  @facts.py:125 - Unable to load custom facts file: /etc/rhsm/facts/empty.facts



Additional info:

The same traceback is thrown when a custom facts file has malformed json, like this...
[root@jsefler-rhel7 ~]# cat /etc/rhsm/facts/malformed.facts
{"malformed_fact":"value" is "misquoted"}

Comment 3 Chris Snyder 2017-04-06 19:51:52 UTC
I have a fix for the exception.

I am currently investigating whether logging in the dbus service works at all. As far as I can tell there is no reason (with my fix) the desired log message should not be written to /etc/rhsm/rhsm.log but yet it is not. Furthermore, I've not seen any log messages coming from the dbus service.

I will continue investigation.

Comment 4 Chris Snyder 2017-04-06 20:45:34 UTC
I have employed the same logic as is done in rhsmd, applied to the dbus services.
The PR with the both fixes necessary for this bug has been attached as an external tracker to this bug.

Comment 7 John Sefler 2017-04-25 18:02:54 UTC
Verifying Version....
[root@jsefler-rhel7 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 0.9.51.21-1
subscription management rules: 5.15.1
subscription-manager: 1.19.9-1.el7
python-rhsm: 1.19.5-1.el7

[root@jsefler-rhel7 ~]# touch /etc/rhsm/facts/empty.facts
[root@jsefler-rhel7 ~]# subscription-manager register
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_auto_testuser1
Password: 
The system has been registered with ID: 441553d0-674f-4033-8145-6ac313626341 

[root@jsefler-rhel7 ~]# tail -f /var/log/rhsm/rhsm.log
2017-04-25 13:58:41,757 [INFO] subscription-manager:22077:MainThread @custom.py:85 - Loading custom facts from: /etc/rhsm/facts/empty.facts
2017-04-25 13:58:41,758 [WARNING] subscription-manager:22077:MainThread @custom.py:40 - Unable to load custom facts file.
2017-04-25 13:58:41,801 [INFO] subscription-manager:22077:MainThread @custom.py:85 - Loading custom facts from: /etc/rhsm/facts/empty.facts
2017-04-25 13:58:41,801 [WARNING] subscription-manager:22077:MainThread @custom.py:40 - Unable to load custom facts file.

Comment 8 errata-xmlrpc 2017-08-01 19:21:47 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, 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-2017:2083


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